For the port you will need to puzzle a little in the core.h: https://github.com/PaulStoffregen/cores ... ore_pins.h
Teensy 4.0 is __IMXRT1062__. This is handy to know since some block only apply to this
Moving from the top
CORE_PIN0_BIT :is which bit of a port is which pin. In this case it is said to be 3 (the 3rd bit).
CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT)) :creates the actual number which is used to write the port.
CORE_PIN0_PORTSET :determines to which port this is written. GPIO6_DR_SET in this case, port 6
Then there is a whole lot of information that is not relevant. It all applies to the __IMXRT1052__. Move until "#endif // __IMXRT1052__"
A lot further down below there is what digitalWrite(0, 1); is translated to:
CORE_PIN0_PORTSET = CORE_PIN0_BITMASK;, which becomes GPIO6_DR_SET = 1<<3
digitalWrite(0, 0); is translated to:
CORE_PIN0_PORTCLEAR = CORE_PIN0_BITMASK;, which becomes GPIO6_DR_CLEAR = 1<<3
Now these functions can only set pins that are 1 in the mask to high (GPIO_DR_SET) or low (GPIO_DR_CLEAR).
A direct write to the port should be GPIO6_DR, followed by the bits that need to be high and low. GPIO6 = 8; should set GPIO6 pin 3 (which was 0) to high, and GPIO6 = 0; should make all pins 0. However this also writes ALL pins on the port to 0, which is bad. The code to just write pin 0 should be:
Code: Select all
byte pinTable[] = {0,3,4,5,6,7,8,9};
void setup() {
for(int i=0; i<8; i++) {
pinMode(pinTable[i],OUTPUT);
}
}
void loop() {
GPIO6_DR = GPIO6_DR | 8;
GPIO6_DR = GPIO6_DR & ~8; //the ~ inverts the 1's and 0's.
}
Looking at the values though I am afraid that there are no full ports broken out on the Teensy 4.0