Help with PIC16f690 and pin address -- CCS C compiler

Thread Starter

johnnyinwa

Joined Jun 24, 2013
59
I am working with the PIC16f690 and the CCS C compiler. I need help with the Output_High (pin) command. I need to know the address of the pin in question. If I'm working with pin 2 (RA5) what is the address of the pin? Where is this data found? On the manufacturer's data sheet there are two addresses given for two different "banks". There are four banks listed -- what is the difference between bank 0 and bank 2? Any help you can give me here would be greatly appreciated. Thanks.
 

Ian Rogers

Joined Dec 12, 2012
1,024
datasheet said:
output_high( )
Syntax: output_high(pin)
Parameters: pin to write to. 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_IO mode is set on port A. Note that doing I/O with a variable instead of a constant will take much longer time.
Ergo

Output_high(PIN_A5);

Bank switching isn't needed in C as the linker does it automatically
 

upand_at_them

Joined May 15, 2010
940
I am working with the PIC16f690 and the CCS C compiler. I need help with the Output_High (pin) command. I need to know the address of the pin in question. If I'm working with pin 2 (RA5) what is the address of the pin? Where is this data found? On the manufacturer's data sheet there are two addresses given for two different "banks". There are four banks listed -- what is the difference between bank 0 and bank 2? Any help you can give me here would be greatly appreciated. Thanks.
The address of the registers are indeed in the datasheet. The TRISA register, which sets the port A pins to outputs or inputs, is located in Bank 1 and mirrored in Bank 3. The PORTA register, which is used for setting the pin output value or reading the input value, is located in Bank 0 and mirrored in Bank 2.
 

MrSalts

Joined Apr 2, 2020
2,374
What is the value for the #define statement for pin 2 -- RA5 on the pic16f690?
First, stop calling it pin2. It is controlled by the 6th digit of two different registers called "TRISA" and "PORTA". Setting TRISA to 0b11011111 will set that GPIO pin, A5, to an output. By default, it is an input when you start. Then, setting that digit to 1 make it HIGH (5v) and setting that digit to 0 will keep it an OUTPUT but it will be 0V (at ground).
 

Ian Rogers

Joined Dec 12, 2012
1,024
What is the value for the #define statement for pin 2 -- RA5 on the pic16f690?
Can you access the include file for THAT chip. I would imagine the address for ALL pic16's will be the same...
BUT!! these will all be defined in that header... if you want to use a general purpose pin just use "PIN_A5" thats why these boffins set it all up.

Going off all your other posts, it seems you are struggling to do anything... CCS compiler may not be the best choice.... Most of us use XC8 so that has the best response... You may be better asking on their forums..
 

Thread Starter

johnnyinwa

Joined Jun 24, 2013
59
Thank you so much!! That's exactly what I wanted. I figured it out for myself but it's awesome to get the right answer. The value is given in the manufacture's data sheet. The listing for the correct address is given in bank 0.
 
Top