Hello everyone,
I am trying to read and store eight(8) GPIO pins simultaneously. The ultimate goal is to complete this operation in the fewest number of CPU clock cycles as possible. One clock cycle would be ideal, but most likely unfeasible. I can't exceed ~10 instruction clocks since I am only allotted 18 clock pulses total for the loop I am writing, and I need some wiggle room for the other operation which is two write a pin high then low again after the 8bits are stored. AVR microcontrollers were easier to do this with using the PINx command, but the ARM microcontroller doesn't seem to support this command. And since I am limited in timing, I can't use the built-in functions like digitalRead(), digitalWrite(), etc. Since each one consumes ~50 clock cycles according to post #3 on an arduino forum: https://forum.arduino.cc/t/how-many-clock-cycles-does-digitalread-write-take/467153/2
I have extensively searched through these forums and came across some information such as using IOMUX to force the pins to act as GPIO when ALT5 is used. And that GPIOx_GDIR = 0xFFFF will set the port to be input, and then GPIOx_DR will read the whole port. I am aware that a port read will read 32 bits, then I will need to truncate the top MSB bits and store only those bits.
I also need some way to write a pin high and low on command preferably in a single clock pulse of the 600MHz CPU clock if possible, so once again, the digitalWrite() and I suspect even the digitalWriteFast() are not fast enough.
A few of the relevant forums/sources I have found so far:
https://forum.pjrc.com/threads/64702-GPIO-ports-and-related-control-register
https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test
https://forum.pjrc.com/threads/6149...-other-board-with-2-cores-to-solve-my-problem
The IMXRT1060 datasheet
I am new to programming microcontrollers with C/Arduino-C/Teensyduino, I have only been trained to use assembly for microcontroller programming and I am very unsure how to program this loop to read and store the 8 parallel pins. I would use a standalone MCU, but adding on a memory peripheral and interfacing with it using assembly sounds to be more effort than it's worth. And so I have landed on using the Teensy 4.0.
Any feedback on how to program this beyond just being told to read the datasheet would be greatly appreciated since the datasheet is pretty convoluted in my opinion.
And thank you Paul, KurtE and TRNPep for your previous posts which have guided me up to this point.
~RRkt
I am trying to read and store eight(8) GPIO pins simultaneously. The ultimate goal is to complete this operation in the fewest number of CPU clock cycles as possible. One clock cycle would be ideal, but most likely unfeasible. I can't exceed ~10 instruction clocks since I am only allotted 18 clock pulses total for the loop I am writing, and I need some wiggle room for the other operation which is two write a pin high then low again after the 8bits are stored. AVR microcontrollers were easier to do this with using the PINx command, but the ARM microcontroller doesn't seem to support this command. And since I am limited in timing, I can't use the built-in functions like digitalRead(), digitalWrite(), etc. Since each one consumes ~50 clock cycles according to post #3 on an arduino forum: https://forum.arduino.cc/t/how-many-clock-cycles-does-digitalread-write-take/467153/2
I have extensively searched through these forums and came across some information such as using IOMUX to force the pins to act as GPIO when ALT5 is used. And that GPIOx_GDIR = 0xFFFF will set the port to be input, and then GPIOx_DR will read the whole port. I am aware that a port read will read 32 bits, then I will need to truncate the top MSB bits and store only those bits.
I also need some way to write a pin high and low on command preferably in a single clock pulse of the 600MHz CPU clock if possible, so once again, the digitalWrite() and I suspect even the digitalWriteFast() are not fast enough.
A few of the relevant forums/sources I have found so far:
https://forum.pjrc.com/threads/64702-GPIO-ports-and-related-control-register
https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test
https://forum.pjrc.com/threads/6149...-other-board-with-2-cores-to-solve-my-problem
The IMXRT1060 datasheet
I am new to programming microcontrollers with C/Arduino-C/Teensyduino, I have only been trained to use assembly for microcontroller programming and I am very unsure how to program this loop to read and store the 8 parallel pins. I would use a standalone MCU, but adding on a memory peripheral and interfacing with it using assembly sounds to be more effort than it's worth. And so I have landed on using the Teensy 4.0.
Any feedback on how to program this beyond just being told to read the datasheet would be greatly appreciated since the datasheet is pretty convoluted in my opinion.
And thank you Paul, KurtE and TRNPep for your previous posts which have guided me up to this point.
~RRkt