Optimizing amount of small SPI transfers per second
Hello,
I'm working on a project where, per SPI channel, I need to:
- Read voltage from four AD4630, 2x6 bytes read and 2x3 bytes read.
- Calculate output
- Set 4 MAX5719 DAC output 4x3 bytes transfer
- Each of them use separate cs pin
I need to handle 3 channels like one described, so the blocking method is not possible.
For now, I manage to achieve a 25 kHZ update loop of a single channel update working in a loop, where after triggering MAX5719, I immediately trigger conversion of AD4630 and another SPI transfers.
My setup consists of:
- STM32H755ZIQ, firmware runs on M7 core
- I set up a project with CubeMX and then modified the HAL SPI DMA TRANSFER/RECEIVE functions to remove all unnecessary boilerplate code
- Access the chip select GPIO by directly modifying the BSRR register
- Inlined a bunch of functions related to handling the interrupts
- Enabled O3 optimization
- Optimised/Removed all data processing and focused only on transfer
My loop is affected by the transfer speed of the SPI in the following way:
- 12.5 MHz SPI transfer -> 19.2 kHZ loop
- 25 MHz SPI transfer -> 23.4 kHZ loop
- 50 MHz SPI transfer -> 25.6 kHZ loop
I had a look a MDMA peripheral for optimising the CS switching and transfer, but it does not have direct access to the SPI register for transferring the data. I don't see ways to provide me with big improvements with just writing to bsrr registers using MDMA.
I look for ideas on how to increase the number (the goal would be to achieve 50 kHz+ loop).
- Is there an ST MCU better fit for transfers like that?
- Are there any MDMA examples that can help me work with the SPI?
- Is there anything more I can check to increase transfer speeds
