![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
arao
Joined: 15 May 2012 Posts: 2
|
question on set_tris_x function |
Posted: Tue May 15, 2012 11:06 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue May 15, 2012 11:12 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
arao
Joined: 15 May 2012 Posts: 2
|
question on set_tris_x function |
Posted: Tue May 15, 2012 1:03 pm |
|
|
I am currently using a PIC18F2680. I referred to the document by just clicking on the ? button on the IDE.
Regards. |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue May 15, 2012 2:00 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 15, 2012 2:08 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Wed May 16, 2012 2:33 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|