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

Newbie question about pin numbering

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








Newbie question about pin numbering
PostPosted: Sat Jan 06, 2007 5:59 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jan 06, 2007 7:22 pm     Reply with quote

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








PostPosted: Sat Jan 06, 2007 8:58 pm     Reply with quote

Many thanks, I think I understand it now Smile
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