Access pin registers

Status
Not open for further replies.

plemon

Member
Hi,

I'm playing around with some arduino lanc code, trying to get it working on my Teensy LC. I'm having a brain freeze about accessing the pin registers.

I am using Pin 0 (TX1) on my Teensy instead of pin 11 as per below, and am using Pin 18 instead of pin 7. Can anyone tell me the pin and port letter for the respective ports 18 and 7 as I can't make them out on my chart.

Here is the snippet code I am trying to reproduce but using pin 0 instead of 11 and pin 18 instead of 7.

#define cmdPinON (PORTD = B10000000) // Set digtal pin 7 (PD7)
#define cmdPinOFF (PORTD = B00000000) // Reset digtal pin 7 (PD7)
#define lancPinREAD (PINB & B00001000) // Reads pin 11 (PB3)
#define lancPin 11

void setup() {
DDRD = DDRD | B10000000; // Config cmdPin as output
DDRB = DDRB & B11110111; // Config lancPin as input
DDRB = DDRB | B00100000; // Config ledPin as output

Cheers,

Phil
 
What about using simply the digitalWriteFast(pin) and digitalReadFast(pin) functions which are just wrappers around the port registers?
 
Status
Not open for further replies.
Back
Top