Teensy 3.2 PORTE and DDRE not recognized when setting i/o registers

Status
Not open for further replies.

Zenbob

Well-known member
Hello, having some trouble using the functions to set I/O registers as described here:

https://www.pjrc.com/teensy/pins.html

Using the Arduino IDE, PORTC and DDRC are recognized, but PORTE and DDRE are not. We are not defining either PORTC or PORTE. The goal is to tri-state PTE0 (Teensy pin 31). What are we doing wrong?

Code:
                  //Input PIN
                            PORTC |= (0<<1);  // https://www.pjrc.com/teensy/pins.html see I/O Registers
                            DDRC |= (1<<1);
                            
                            //Enable PIN 
                            PORTE |= (0<<0);  // https://www.pjrc.com/teensy/pins.html see I/O Registers
                            DDRE |= (1<<0);

Menu:1003: error: 'PORTE' was not declared in this scope
PORTE |= (0<<0); // https://www.pjrc.com/teensy/pins.html see I/O Registers

^

Menu:1004: error: 'DDRE' was not declared in this scope
DDRE |= (1<<0);

^

Thanks much for any suggestions.
 
Oh, that page is old info for Teensy 2.0 and Teensy++ 2.0.

Teensy 3.x has limited emulation of those old AVR registers, but only ports B, C, and D (and emulating the pin mapping of Arduino Uno). When you use PORTC, you're not actually accessing the hardware directly. It's a C++ object which uses operator overloading to software emulate the AVR chip registers, so programs written for old 8 bit boards can run on the newer 32 bit boards.

For the fastest single pin access, use digitalWriteFast(pin, LOW) or digitalWriteFast(pin, HIGH). While this has Arduino-like syntax, as long as you use a constant for the pin number it will always compile to the fastest code using direct hardware access. Best of all, you don't need to put any register names into your code, so it should be compatible with future boards.
 
Thanks for the reply Paul. Unfortunately we designed a circuit that relied on high impedance on PTE0. We tried setting PTE0 to Input, but it doesn't seem to fix the issue so we will continue troubleshooting at the hardware end and probably change the circuit design.
 
Status
Not open for further replies.
Back
Top