I’m interested in using an SPI interface in DMA mode, specifically to bit-bang some Neopixel LEDs, a technique I’ve used elsewhere. DMA is essential here because other interrupt-driven services would disrupt the timing of a non-DMA solution.
Can anyone point me to an example that uses the HAL functions for doing SPI DMA transfers? I’ve been unable to find one so far.
Thanks!
I’ve had little success finding example code, and the HAL functions are quite challenging to navigate.
I have discovered that the Arduino IDE’s SPI library works well for my purpose, so DMA won’t actually be needed. The interrupts of the IRMP library I’m also using only last 6 us or so, so they don’t trash the bit-banged pulses to my Neopixels. It’s great to have a 48 MHz MCU in this module.
The SPI library is coded to use the following pins (this wasn’t especially obvious, so I’ll note it here for reference):
MOSI 12
MISO 13
SCK 11
In my application, I call SPI.begin() and SPI.beginTransaction(spiSettings) in my initializer, then call SPI.transferOut() to bang the bits to the LEDs. Works fine.
Yes, SPI supports DMA for one-way transfers which is all you would need for LED control. (Ambiq has told me that DMA is not supported for full duplex transfers)
The HAL will attempt to use DMA by default (as far as I can tell)
Here’s one example that could help:
https://github.com/sparkfun/AmbiqSuiteS … s/iom_fram
Here’s the nonblocking SPI transfer function declaration:
https://github.com/sparkfun/AmbiqSuiteS … iom.h#L787
That will be useful. Thanks!