Reading and writing words on Teensy 4.0

Status
Not open for further replies.

Deane

Well-known member
I have to use an external 10 bit A/D on my project because the internal one is not fast enough. I was going to have the A/D stuff data into a FIFO memory but I am finding that these chips are difficult to work with and do not have 10 bits. So I want to create a little test code to see how fast I can read a 10 bit word off the data bus, 20 times, and put those in a 20 word array in RAM. I am guessing that writing to RAM will be the fastest way to do this (vs EEPROM or FLASH). I need to do all 20 reads and writes in 2 us. to make this work.
Also, I know there are some added commands for Teensy such as digitalwritefast. Is there a listing somewhere of all these extra commands? I don't see any 16 bit word commands in the Arduino code, just byte and bit commands.
Thanks, I have only minimal C experience.
 
Follow the links in this post - one should demo a port read of all the pins on that port :: Teensy-4-1-8-Bit-Parallel-I-O

That post is from mid 2020 - there may be other newer posts but IIRC at least one demonstrated reading as desired.

On Teensy 4.x port reads are 32 bit reads - all I/O on that port - where you want to pick one with 10 on the same port - if possible or two as may be needed on T_4.0.

Pins are distributed across the board for the function they provide - not by Port association. There are tables of association or reading the T_4.0 schematic will show the port index bit going to pins.
 
There is this page with a sample sketch that should run and provide a table of the PIN to PORT mapping :: TeensyUser/doc/wiki/Mapping-Pins-to-Ports

Look around there perhaps for port read usage? I didn't see it showing up ...

@luni - is there a section with demo of parallel port read and write on Teensy 4.x?
 
@defragster Thanks for the quick and detailed response. There is a lot going on here. I will have to study the code and try a few examples.
If it takes 9 cycles, how long is that at 600 MHz clock speed? Is it 1/600 million seconds per cycle?
 
The T4 is a dual issue processor so you can get upto 1200 million instruction cycles per second with luck,
but yes the clock period is 1.67ns = 1/600000000s, so 9 clocks is 15ns
 
Status
Not open for further replies.
Back
Top