T3.1 fast port read

Status
Not open for further replies.

oric_dan

Well-known member
I'm kind of new with Teensy techo-details. I did a search, but didn't find anything that looked directly related.

On my T3.1, I am wanting to read an 8-bit port as quickly as possible, namely PortD where I can connect external signals to PTD0..PTD7 (ie, pins 2,14,7,8,6,20,21,5) conveniently. I have elsewhere configured the individual pins (2,14,...,5) as inputs using pinMode(). I've tried the port grab 2 ways that both appear to work.

Code:
uint8_t imgBuff[16384];
.........
  for( int i=0; i<SAMPSZ; i++) {
    //imgBuff[i]=PIND; 
    imgBuff[i]=(uint8_t)(GPIOD_PDIR & 0xFF);
  }
The first scheme (PIND) takes abut 550nsec per sample, the second about 94nsec. Are these the best and quickest ways to do the 8-bit port grab? Is the syntax correct with the GPIOD_PDIR scheme? Is there anything I am missing? Thanks.
 
Last edited:
Status
Not open for further replies.
Back
Top