I have a question about achieving instant / real time SPI bursts that are triggered from a GPIO pin. I know other MCU have DMAs that can be triggered by an external event (GPIO, timer, etc…). I am wondering if this is possible on the Colibri IMX7D?
To draw a picture of what I am doing and why, I have an external FPGA connected to the SOM. The FPGA has a small FIFO that it fills up with sensor data. When the FIFO is half full, the FPGA asserts a GPIO pin that indicates a memory read is required. Ideally I would like to service this read request as fast as possible. If the read request is not serviced fast enough, the FPGAs FIFO will overflow and data is lost. Under normal conditions the FPGA asserts the pin about 1 a mille-second, maybe a bit faster.
I tried using an interrupt method, but the overhead is so high, there is too much latency. By the time the SPI actually starts bursting, the FIFO overflows and the data is lost.
I tried a polling method, where a real-time thread (I updated the kernel to real-time as well) polls the pin every 100 us, but every once in a while there are “lags” and the request is not services fast enough. I am not sure why this happens, but even if I could fix it, I do not like this method. It is clunky and consumes a lot of CPU resources.
My last options are:
- Use the M4 Core for all real-time IO. This can be done via interrupts (real-time) and then using shared memory, I can pass data from the M4 to my application.
- Use DMA and external events. This way is completely hardware driven.
My questions are:
- Is the DMA method possible?
- How would I set it up?
- Do I need to mmap the DMA configuration / control registers and manual change them?
- Can I do this through Linux and have it permanent / semi permanent so that Linux does not take the DMA back and break my application?