| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| rajasekar 
 
 
 Joined: 02 May 2008
 Posts: 1
 
 
 
			    
 
 | 
			
				| compiler problem |  
				|  Posted: Fri May 02, 2008 11:17 am |   |  
				| 
 |  
				|   I am using 16F684 with ICD in debugging mode. I am getting the following error.
 
 My code is
 int16 a,b;
 
 void main()
 {
 
 setup_adc_ports(NO_ANALOGS|VSS_VDD);
 setup_adc(ADC_OFF);
 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
 setup_timer_1(T1_DISABLED);
 setup_timer_2(T2_DISABLED,0,1);
 setup_comparator(NC_NC_NC_NC);
 setup_vref(FALSE);
 //   setup_oscillator(False);
 for(;;){
 a=563;
 b=500;
 if(a < b)a=0;
 else a =1;
 // TODO: USER CODE!!
 }
 
 the if statement always considers "a & b " as characters and "a" becomes zero.......!!!!
 Am I missing any compiler option... Please advice....
 
 
 Thanks in advance
 _________________
 hi
 |  |  
		|  |  
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri May 02, 2008 11:31 am |   |  
				| 
 |  
				|  	  | Quote: |  	  | the if statement always considers "a & b " as characters | 
 There is no way that it considers them to be characters.  The compiler
 can't do that.   It can't magically turn a variable name into a character.
 The problem is caused by something else.   It's probably caused by
 some error that you are making in the operation of the compiler or the
 CCS debugger.
 
 I made the test program shown below, and ran it in the MPLAB simulator.
 I put a breakpoint on the delay_cycles() line and displayed 'a' in a Watch
 window.   I then pressed the F9 to run to the breakpoint, and the watch
 window showed the value of 'a' is 1.  I pressed F9 several more times
 to do it again, and the value is always 1.   I tested this with compiler
 version 4.071.
 
  	  | Code: |  	  | #include <16F684.H>
 #fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
 #use delay(clock = 4000000)
 
 int16 a,b;
 
 void main()
 {
 
 setup_adc_ports(NO_ANALOGS|VSS_VDD);
 setup_adc(ADC_OFF);
 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
 setup_timer_1(T1_DISABLED);
 setup_timer_2(T2_DISABLED,0,1);
 setup_comparator(NC_NC_NC_NC);
 setup_vref(FALSE);
 // setup_oscillator(False);
 for(;;){
 a=563;
 b=500;
 if(a < b)a=0;
 else a =1;
 delay_cycles(1);
 }
 
 }
 | 
 |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |