|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Newbie question about pin numbering |
Posted: Sat Jan 06, 2007 5:59 pm |
|
|
Hi, I'm new to PICs (having done a bit with BASIC Stamps). I'm trying to figure out how the port/bits map to pins on the microcontroller. My microcontroller (a PIC12C672) has 8 pins. If I wanted to make pin 7 high, what would I pass as a parameter to output_high?
Here's what the documentation on output_high states, but I must be missing some fundamental concept because I don't understand what the port and bits signify:
Pins are defined in the devices .h file. The actual value is a bit address. For example, port a (byte 5) bit 3 would have a value of 5*8+3 or 43. This is defined as follows: #define PIN_A3 43. The PIN could also be a variable. The variable must have a value equal to one of the constants (like PIN_A1) to work properly. The tristate register is updated unless the FAST_I0 mode is set on port A. Note that doing I/0 with a variable instead of a constant will take much longer time
[/i][/quote] |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jan 06, 2007 7:22 pm |
|
|
Look at the list of available i/o pins, which is given at the top of the
12C672.H file, and use those constants with the CCS pin i/o functions.
Example:
Code: |
output_low(PIN_A0);
output_high(PIN_A0);
|
You don't have to consider how the constant is constructed, from
a port address and a bit number. Just drop the constant into the
function as a parameter, and it will work.
The 12C672.H file is in this directory:
c:\Program Files\Picc\Devices |
|
|
Guest
|
|
Posted: Sat Jan 06, 2007 8:58 pm |
|
|
Many thanks, I think I understand it now |
|
|
|
|
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
|