| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			mattmab
 
 
  Joined: 13 Mar 2004 Posts: 2
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| int32 | 
			 
			
				 Posted: Sat Mar 13, 2004 11:55 pm     | 
				     | 
			 
			
				
  | 
			 
			
				does anyone understand why this wont work? it seems i cant initialze leds to hex 4000.
 
thanks ahead - matt
 
 
#case
 
#include <16f876.h>
 
#device	*=16 ICD=TRUE
 
#use delay( clock=11059000 )
 
int32	leds = 1;
 
void main() {
 
	leds = 0x4000;
 
	} | 
			 
		  | 
	
	
		  | 
	
	
		
			Ttelmah Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				| Re: int32 | 
			 
			
				 Posted: Sun Mar 14, 2004 3:42 am     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | mattmab wrote: | 	 		  does anyone understand why this wont work? it seems i cant initialze leds to hex 4000.
 
thanks ahead - matt
 
 
#case
 
#include <16f876.h>
 
#device	*=16 ICD=TRUE
 
#use delay( clock=11059000 )
 
int32	leds = 1;
 
void main() {
 
	leds = 0x4000;
 
	} | 	  
 
 
Should work. Try declaring the constant as a long - so:
 
leds= 0x4000L;
 
 
Sometimes the compiler is less than 'intelligent' about such things...
 
 
Best Wishes | 
			 
		  | 
	
	
		  | 
	
	
		
			mattmab
 
 
  Joined: 13 Mar 2004 Posts: 2
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| int32a | 
			 
			
				 Posted: Sun Mar 14, 2004 9:59 pm     | 
				     | 
			 
			
				
  | 
			 
			
				        
 
nope,4000L dont work either, it takes it as a 16 bit.  it works if i use make32(), but that seems like a poor way. does 32 bit math work? i never checked...
 
thankws - matt | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sun Mar 14, 2004 10:51 pm     | 
				     | 
			 
			
				
  | 
			 
			
				It actually does work.   If I take your code here,
 
 	  | Code: | 	 		  #case 
 
#include <16f876.h> 
 
#device *=16 ICD=TRUE 
 
#use delay( clock=11059000 ) 
 
int32 leds = 1; 
 
void main() { 
 
leds = 0x4000; 
 
} | 	  
 
and compile it with PCM vs. 3.184, I get this result in the .LST file:
 
 	  | Code: | 	 		  0011 01A3       00277 CLRF   23
 
0012 01A2       00278 CLRF   22
 
0013 3040       00279 MOVLW  40
 
0014 00A1       00280 MOVWF  21
 
0015 01A0       00281 CLRF   20 | 	  
 
The symbol table shows that 'leds' is at address 0x20:
 
 
The ASM code is setting the memory locations as follows:
 
0x23 = 0
 
0x22 = 0
 
0x21 = 0x40
 
0x20 = 0
 
Since CCS stores variables in Intel Lo-Hi format, this means
 
that 'leds' = 00 00 40 00 which is correct.
 
 
I suspect that the problem is in how you are viewing the 'leds' variable.
 
For example, if you're using printf, you need to specify the format
 
string as "%lx", and not "%x", in order to display a 16 or 32-bit number. | 
			 
		  | 
	
	
		  | 
	
	
		 |