Most Efficient solution for reading ADC through SPI
Hi,
i'm always looking for the most efficient implementation of code in my STM controllers and was wondering which is the most efficient way to implement ADC reading from an external ADC chip trough SPI in an STM32G4 controller.
The ADC (MCP3461/2/4) have a continious mode and set an interrupt line after each conversion. The 16 bit adc value is present in a buffer register to read trough SPI.
I see these 3 choises:
- Using HAL_SPI_Receive_DMA, but as the ADC send 16 bits at a time i'm not sure this is the best solution. Each ADC conversion interrupt i need to start the DMA which fire a Transfer-Complete interrupt to read the actual value.
- Using HAL_SPI_Receive_IT, Each ADC conversion interrupt i need to start the interrupt driven SPI read which fire a Transfer-Complete interrupt to read the actual value.
- Just by reading the 16 bits each ADC conversion interrupt with the blocking HAL_SPI_Receive function as this goes super fast.
i'm wondering is the overhead in the first 2 option makes it worthwile to use the non blocking SPI functions?
Thank you
