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 not being set correctly?

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



Joined: 20 Jul 2008
Posts: 32
Location: Brisbane, Australia

View user's profile Send private message

TRIS not being set correctly?
PostPosted: Wed Dec 31, 2008 9:27 pm     Reply with quote

Judging by the number of forum entries, this should not be worth putting in another post! But I am confused. The gory details are 18F2620, PCWH V4.079, XP.
What I find is that I expect pin C3 to be an output. With the followng code and looking at the C/ASM output
Code:

#use fixed_io( c_outputs=PIN_C0, PIN_C3  )

...

....................       Output_low( PIN_C3 );
*
0FFC:  MOVLW  FB
0FFE:  MOVWF  F94
1000:  BCF    F8B.3


C3 always is an input, from measurements on the pin. The trisc is consistent with C3 being an input. The Output_low should not be using FB ( The one bit in FB that is set as output is for PWM module ) for setting the trisc. It should be more like F3.

If I comment out the "fixed_io" I get the same result (FB for trisc).

So sadly, what obvious mistake am I making here? Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 31, 2008 10:35 pm     Reply with quote

Quote:
So sadly, what obvious mistake am I making here

Not posting a test program.

Here's the output of the test program shown below. It's correct.
This was compiled with vs. 4.079. Since you're getting something
different, post (very short) test program that shows the problem.
Code:
.................... void main() 
.................... { 
00004:  CLRF   TBLPTRU
00006:  BCF    RCON.IPEN
00008:  CLRF   FSR0H
0000A:  CLRF   FSR0L
0000C:  MOVF   ADCON1,W
0000E:  ANDLW  C0
00010:  IORLW  0F
00012:  MOVWF  ADCON1
00014:  MOVLW  07
00016:  MOVWF  CMCON
.................... 
.................... output_low(PIN_C3); 
00018:  MOVLW  F6     // This is the correct TRIS.
0001A:  MOVWF  TRISC
0001C:  BCF    LATC.3
.................... 
.................... 
.................... while(1);       
0001E:  BRA    001E
.................... }


Code:
#include <18F2620.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000) 

#use fixed_io(c_outputs=PIN_C0, PIN_C3)
     
//====================================
void main()
{

output_low(PIN_C3);

while(1);     
}
Herbert



Joined: 20 Jul 2008
Posts: 32
Location: Brisbane, Australia

View user's profile Send private message

PostPosted: Wed Dec 31, 2008 10:42 pm     Reply with quote

Offending code is in the middle of something much bigger. I was hoping there might be an obvious reason for this behaviour. Gutting the code to get it down to a bit of test code that shows the problem involves a bit of pain. Looks like I may have to do this.
Herbert



Joined: 20 Jul 2008
Posts: 32
Location: Brisbane, Australia

View user's profile Send private message

PostPosted: Thu Jan 01, 2009 12:16 am     Reply with quote

Problem solved. Had a second "#use fixed_io..." hidden away in an include file that came after the one I had indicated, so it was in effect at the point I was looking at in the code. Thanks PCM, the test code you showed did make me think in terms of this possibility. Very Happy
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