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

question on set_tris_x function

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



Joined: 15 May 2012
Posts: 2

View user's profile Send private message

question on set_tris_x function
PostPosted: Tue May 15, 2012 11:06 am     Reply with quote

I see the following in CCS documentation regarding set_tris_x().
SET_TRIS_B( 0x0F );
// B7,B6,B5,B4 are outputs
// B15,B14,B13,B12,B11,B10,B9,B8,B3,B2,B1,B0 are inputs
I’m trying to understand if this is an error in documentation.

If each bit represents a PIN, then ONLY Bits 0-3 are INPUTS and Bits 4-7 are OUTPUTS.

The documentation talks about B15-B8 as inputs as well?? Why?
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue May 15, 2012 11:12 am     Reply with quote

You are reading the manual for the PCHD compiler (for PIC's like the PIC24), which perform 16bit I/O by default.
Are you using a PIC24, or a PIC16/PIC18?.
On the latter, the ports are only 8bits wide.

Best Wishes
arao



Joined: 15 May 2012
Posts: 2

View user's profile Send private message

question on set_tris_x function
PostPosted: Tue May 15, 2012 1:03 pm     Reply with quote

I am currently using a PIC18F2680. I referred to the document by just clicking on the ? button on the IDE.

Regards.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue May 15, 2012 2:00 pm     Reply with quote

It does look a little confusing. But the best way to resolve this and similar issues is to compile a trivial program and look at the assembly listing.

Please share the result for the next person with the same problem.
_________________
The search for better is endless. Instead simply find very good and get the job done.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 15, 2012 2:08 pm     Reply with quote

Quote:

I am currently using a PIC18F2680.

Here is the PDF manual for your compiler. Download it and put it on
your Windows desktop. Look up set_tris_x in this manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed May 16, 2012 2:33 am     Reply with quote

I'm wondering if your IDE has somehow got the PCD manual linked by mistake:
On mine, if working with a 16bit PIC, the manual gives:
Code:

Examples:
 SET_TRIS_B( 0x0F );

   // B7,B6,B5,B4 are outputs

   // B15,B14,B13,B12,B11,B10,B9,B8, B3,B2,B1,B0 are inputs

but if working with a 8bit PIC, gives:
Code:

Examples:
 SET_TRIS_B( 0x0F );

   // B7,B6,B5,B4 are outputs

   // B3,B2,B1,B0 are inputs

Getting the wrong manual, will happen if you initialise the project having selected the PIC24 mode, then switch to using the PIC18 mode. The IDE remembers the manual link for the original selected mode....

Something like this has happened to you. Selecting the manual yourself (either by loading the pdf manual, or by selecting the .chm file directly in the compiler directory), will hopefully give you the right manual.

Best Wishes
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