CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

TRIS C

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fastlink30



Joined: 14 May 2007
Posts: 33

View user's profile Send private message

TRIS C
PostPosted: Mon Jun 04, 2007 4:19 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 10:18 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 10:33 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 12:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 12:54 pm     Reply with quote

aha, thank you for the info,now understand

strange ccs haven't fixed this problem
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 05, 2007 1:04 pm     Reply with quote

They may not know about it. Report the bug to CCS tech support.
fastlink30



Joined: 14 May 2007
Posts: 33

View user's profile Send private message

PostPosted: Thu Jun 07, 2007 10:26 am     Reply with quote

i do

they reported this bug will be solved in the next release
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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