2026-01-07 7:50 AM
Hello!
I am interfacing an ADS131M02 ADC to the STM32C0116-DK board using SPI for a project I am developing on live streamings. I am able to read SPI Data using the HAL polling functions (HAL_SPI_TransmitReceive), however that created unwanted delay between bytes and I tried swithing to DMA to improve performance.
Configuration:
This is the result with prescaler set to 4 (12 Mbits/s). (Pink: MISO, Blue: SCK), the data is correct.
With the Prescaler set to 2 (24MBits/s) (Pink: MISO, Blue: SCK). The clock does not even try (the pulse is 3us)
The Pseudocode I am using:
/** Simplified code **/
uint8_t newData = 0;
// This is never called if the SPI prescaler is set to:SPI_BAUDRATEPRESCALER_2
// With SPI_BAUDRATEPRESCALER_4 works.
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef* hspi) {
newData = 1;
}
void main(void)
{
// All CubeMX initializations
// Clock configured to 48 MHz.
HAL_SPI_Receive_DMA(...);
while(1)
{
if(newData){
newData = 0;
HAL_SPI_Receive_DMA(...);
}
// Mandatory othwerwise wont work in Release:
__asm__("nop");
}
}
Debuging the problem, I found out that the DMA interrupt for the TX channel is triggered, however the DMA for the RX channel is never triggered. I tried moving the RX DMA from Ch3 o Ch1 with no luck. I would say there is something messing up with the DMA interrupts and the SPI.
Am I missing something?
Solved! Go to Solution.
2026-01-07 8:12 AM
Make sure pin speed is set to VERY_HIGH.
You probably aren't going to have complete success at 24 MHz if the board is pigtailed. Interference starts to be an issue in this region.
2026-01-07 8:02 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution for best results.
In particular how, exactly, are you connecting the ADS131M02 ADC to the STM32C0116-DK?
Please show a schematic and some good, clear photographs.
Hint: long flying leads are not going to do well at 24MHz ...
What is the sampling rate of your logic analyser?
Have you looked at the lines with an oscilloscope?
At these speeds, analogue effects can become significant...
2026-01-07 8:12 AM
Make sure pin speed is set to VERY_HIGH.
You probably aren't going to have complete success at 24 MHz if the board is pigtailed. Interference starts to be an issue in this region.
2026-01-07 8:13 AM
Thank you for your reponse, I had it connected with 10cm leads, however, since the clock is generated from the STM32C011 I have disconnected the SCK signal from the ADC, and now I am measuring the clock output from the STM32 directly from the pin headers of the devkit.
The sampling rate of the logic analyzer was set to 50MHz, but I have probed with the oscilloscope and got the same result: A 3-4us pulse but nothing else.
2026-01-07 8:15 AM
Thank you very much!!! That was the answer, omg, by default the code generated from the CubeMX set the GPIO speed to LOW. I just changed to VERY_HIGH and started working!
Shame on me! Thank you for your support!
2026-01-07 8:16 AM
What you set the pin speed to ?
-> Make sure pin speed is set to VERY_HIGH.