| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| Ivar Boer Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Much ROM memory used when declaring RAM |  
				|  Posted: Tue Jan 07, 2003 3:01 am |   |  
				| 
 |  
				| Dear all, 
 Iam using an PIC16F877 for a fan controller project with a 16 bits RAM pointer.
 At this moment my ROM usage is 89\%.
 
 When iam declaring 3 bytes (3 * int8) my ROM usage is increased from 89\% to 92\%.
 
 Can someone tell why this is happening and how i can resolve this problem?
 (I need a quick answer to be in time for my finishing date)
 
 Thanks!
 
 Ivar
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10493
 |  |  
		|  |  
		| Tomi Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Re: Much ROM memory used when declaring RAM |  
				|  Posted: Tue Jan 07, 2003 6:11 am |   |  
				| 
 |  
				| <font face="Courier New" size=-1>Try to declare your new variables as close as possible to the other variables used in the same functions. Place your frequently used variables onto the first page. Handling variables involves page handling and if you are not really lucky then you can write a program where the every second lines contain page swapping. Here is a piece of code for example (check your code for page bit handling):
 0000                00630 .................... for (bytecnt=0;bytecnt<4;bytecnt++) {
 014E 1703           00631 BSF    03,6
 014F 01AA           00632 CLRF   2A
 0150 1303           00633 BCF    03,6
 0151 3004           00634 MOVLW  04
 0152 1703           00635 BSF    03,6
 0153 022A           00636 SUBWF  2A,W
 0154 1C03           00637 BTFSS  03,0
 0155 2958           00638 GOTO   158
 0156 1303           00639 BCF    03,6
 0157 2BA8           00640 GOTO   3A8
 0158 1303           00641 BCF    03,6
 0000                00642 .................... if (buff & bits[bytecnt]) {
 0159 1703           00643 BSF    03,6
 015A 082A           00644 MOVF   2A,W
 015B 1303           00645 BCF    03,6
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10498
 |  |  
		|  |  
		| Ivar Boer Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Re: Much ROM memory used when declaring RAM |  
				|  Posted: Tue Jan 07, 2003 10:13 am |   |  
				| 
 |  
				| Thank you very much for your answer. 
 I think this could help a bit for general programming, but the problem is that a lot of ROM is used without using the RAM members in my code, so this is not the reason.
 
 
 :=<font face="Courier New" size=-1>Try to declare your new variables as close as possible to the other variables used in the same functions. Place your frequently used variables onto the first page.
 :=Handling variables involves page handling and if you are not really lucky then you can write a program where the every second lines contain page swapping. Here is a piece of code for example (check your code for page bit handling):
 :=0000                00630 .................... for (bytecnt=0;bytecnt<4;bytecnt++) {
 :=014E 1703           00631 BSF    03,6
 :=014F 01AA           00632 CLRF   2A
 :=0150 1303           00633 BCF    03,6
 :=0151 3004           00634 MOVLW  04
 :=0152 1703           00635 BSF    03,6
 :=0153 022A           00636 SUBWF  2A,W
 :=0154 1C03           00637 BTFSS  03,0
 :=0155 2958           00638 GOTO   158
 :=0156 1303           00639 BCF    03,6
 :=0157 2BA8           00640 GOTO   3A8
 :=0158 1303           00641 BCF    03,6
 :=0000                00642 .................... if (buff & bits[bytecnt]) {
 :=0159 1703           00643 BSF    03,6
 :=015A 082A           00644 MOVF   2A,W
 :=015B 1303           00645 BCF    03,6
 :=
___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10502
 |  |  
		|  |  
		| R.J.Hamlett Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Re: Much ROM memory used when declaring RAM |  
				|  Posted: Tue Jan 07, 2003 10:29 am |   |  
				| 
 |  
				| :=Dear all, :=
 :=Iam using an PIC16F877 for a fan controller project with a 16 bits RAM pointer.
 :=At this moment my ROM usage is 89\%.
 :=
 :=When iam declaring 3 bytes (3 * int8) my ROM usage is increased from 89\% to 92\%.
 :=
 :=Can someone tell why this is happening and how i can resolve this problem?
 :=(I need a quick answer to be in time for my finishing date)
 :=
 :=Thanks!
 :=
 :=Ivar
 Firstly, if you are using '#zero_ram', in the code, then adding new variables, will correspond to other addresses to be cleared. Secondly, if you declare a variable with a statement like:
 int fred=8;
 Then the code to initialise the variable will be added.
 A simple declaration like:
 int fred;
 will normally add nothing to the code involved, _but_ if the system has to move another variable into a different memory bank to make way for this, then extra bank switching code will be added, even if the new variable is not used. It is allways worth declaring commonly used variables together, since this tends to result in these being placed together in RAM.
 
 Best Wishes
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10505
 |  |  
		|  |  
		|  |  
  
	| 
 
 | You cannot post new topics in this forum You cannot reply to topics in this forum
 You cannot edit your posts in this forum
 You cannot delete your posts in this forum
 You cannot vote in polls in this forum
 
 |  
 Powered by phpBB © 2001, 2005 phpBB Group
 
 |