Hi, I'm new to teensy and this forum and I'm looking for some help regarding my Teensy 3.5 project. When reading the "How-to Tips" the section "Using I/O pins" talks about reading a full register (8bit) which I would like to use for my project (reading external hardware which offers a byte interface). Unfortunately I have not found anything (yet) to read a full register (8, 16, 32 bit) with one command for the teensy 3.5. When scanning the "Teensy 3.5 & 3.6 Schematic" it looks to me that the registers and pins are not used in a consecutive way - but I might be wrong. Right now I have a working solution at bit basis:
byte read_byte() {
byte b = 0;
b |= digitalRead(A0)<<0;
b |= digitalRead(A1)<<1;
b |= digitalRead(A2)<<2;
b |= digitalRead(A3)<<3;
b |= digitalRead(A4)<<4;
b |= digitalRead(A5)<<5;
b |= digitalRead(A6)<<6;
b |= digitalRead(A7)<<7;
return b;
}
which does not look very efficient to me.
Thanks!
byte read_byte() {
byte b = 0;
b |= digitalRead(A0)<<0;
b |= digitalRead(A1)<<1;
b |= digitalRead(A2)<<2;
b |= digitalRead(A3)<<3;
b |= digitalRead(A4)<<4;
b |= digitalRead(A5)<<5;
b |= digitalRead(A6)<<6;
b |= digitalRead(A7)<<7;
return b;
}
which does not look very efficient to me.
Thanks!