![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Luig Guest
|
problems with port b using can |
Posted: Fri Jul 21, 2006 2:12 pm |
|
|
When I use can tx and rx I have problems using other pins in port b
Can You explain to me the meaning of the following instruction:
set_tris_b((*0xF93 & 0xFB ) | 0x08); //b3 is out, b2 is in
taken from 18f4580 can driver?
Thank You |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Jul 21, 2006 2:29 pm |
|
|
0xF93, is the address of the 'TRIS_B' register.
*0xF93, gives you the _contents_ of this register (the current TRIS value).
This is then 'anded' with 0xFB - 11111011 in binary, which just clears bit 2, to be an output, without affecting any other bits. The result of this is then 'ored' with 00001000, which turns on bit 3, making this an input, and the whole thing is written back to the TRIS register.
This is the way to change the required two bits, without changing anything else, and should work fine. However the description is the 'wrong way round' for what it does. It sets b3 as an input, and b2 as an output. This is probably a 'typing error', and provided the CAN actually works, the bits changed are obviously 'right'.
It should not have any affect on the other TRIS bits at all.
You need to 'look elsewhere' if you are having troubles with the other pins on port B. Remember there are a lot of peripherals multiplexed onto this port, including the LVP pins...
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
|