| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			fastlink30
 
 
  Joined: 14 May 2007 Posts: 33
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| TRIS C | 
			 
			
				 Posted: Mon Jun 04, 2007 4:19 am     | 
				     | 
			 
			
				
  | 
			 
			
				16f877 pcwh 4.033
 
 
why after set_tris_c() the result is 0?
 
i use pn c6/7 for serial i/o and fast i/o.
 
 
 	  | Code: | 	 		  
 
void main() {
 
   int8 car;
 
   int16 tmp;
 
   int8 mot;
 
   char buff[6];
 
   
 
   setup_adc_ports(NO_ANALOGS);
 
   setup_adc(ADC_OFF);
 
   setup_psp(PSP_DISABLED);
 
   setup_spi(SPI_SS_DISABLED);
 
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
 
   setup_timer_2(T2_DISABLED,0,1);
 
   
 
   port_b_pullups(FALSE);
 
   
 
   set_tris_a(0b00000000);
 
   set_tris_b(0b00000000);
 
   set_tris_c(0b10000000);// 0 = output
 
printf("%u \r",get_tris_c());
 
 | 	 
  | 
			 
		  | 
	
	
		  | 
	
	
		
			fastlink30
 
 
  Joined: 14 May 2007 Posts: 33
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Jun 05, 2007 10:18 am     | 
				     | 
			 
			
				
  | 
			 
			
				i tried also
 
 	  | Code: | 	 		  
 
   set_tris_b(0b10000011);
 
   set_tris_c(0b10000011);
 
printf("[%u %u] \r",get_tris_b(),get_tris_c());
 
 | 	  
 
 
result:
 
[131 0]
 
 
set_Tris_c() seems dont change value
 
 
where i'm wrong? maybe i don't disable somethng? | 
			 
		  | 
	
	
		  | 
	
	
		
			fastlink30
 
 
  Joined: 14 May 2007 Posts: 33
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Jun 05, 2007 10:33 am     | 
				     | 
			 
			
				
  | 
			 
			
				found the problem!
 
if i hide
 
#use fast_io(C)
 
 
all work ok....  but why? i can't use fast_io on port c? | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Jun 05, 2007 12:23 pm     | 
				     | 
			 
			
				
  | 
			 
			
				In fast_io mode, the get_tris_c() function returns 0.   It doesn't read
 
the TRISC register or a shadow register.  It just returns 0. That's a bug.
 
 
Here's the ASM code produced for fast_io mode.
 
Notice that it loads W with 0x00 and then puts
 
W into 'tmp'.
 
 	  | Code: | 	 		  
 
...  set_tris_c(0b10000000);  
 
000D:  MOVLW  80
 
000E:  MOVWF  07      // TRISC = 0x80
 
...  tmp = get_tris_c(); 
 
000F:  MOVF   00,W    // W = 0x00
 
0010:  BCF    03.5    // Bank 0
 
0011:  MOVWF  21      // tmp = W  (tmp = 0x00)
 
 | 	  
 
 
But it works OK for Port B:
 
 	  | Code: | 	 		  
 
... set_tris_b(0b10000000);  
 
0012:  MOVLW  80
 
0013:  BSF    03.5
 
0014:  MOVWF  06     // TRISB = 0x80
 
... tmp = get_tris_b(); 
 
0015:  MOVF   06,W   // Read TRISB
 
0016:  BCF    03.5
 
0017:  MOVWF  21     // Put it into 'tmp'
 
 | 	  
 
 
 
Reading TRISC works OK if you don't enable fast_io mode
 
for Port C.   Then it reads the TRIS from the Shadow register.
 
 	  | Code: | 	 		  
 
...  set_tris_c(0b10000000);  
 
000D:  MOVLW  FF
 
000E:  BCF    03.5
 
000F:  MOVWF  20
 
0010:  MOVLW  80
 
0011:  BSF    03.5
 
0012:  MOVWF  07
 
0013:  BCF    03.5
 
0014:  MOVWF  20
 
...  tmp = get_tris_c(); 
 
0015:  MOVF   20,W    // Read shadow reg. for TRISC
 
0016:  MOVWF  21    // and put it in 'tmp'
 
 
 | 	    
 
It also does this with vs. 4.040. | 
			 
		  | 
	
	
		  | 
	
	
		
			fastlink30
 
 
  Joined: 14 May 2007 Posts: 33
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Jun 05, 2007 12:54 pm     | 
				     | 
			 
			
				
  | 
			 
			
				aha, thank you for the info,now understand
 
 
strange ccs haven't fixed this problem | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Jun 05, 2007 1:04 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| They may not know about it.    Report the bug to CCS tech support. | 
			 
		  | 
	
	
		  | 
	
	
		
			fastlink30
 
 
  Joined: 14 May 2007 Posts: 33
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Jun 07, 2007 10:26 am     | 
				     | 
			 
			
				
  | 
			 
			
				i do
 
 
they reported this bug will be solved in the next release | 
			 
		  | 
	
	
		  | 
	
	
		 |