Skip to main content
Visitor II
January 7, 2026
Solved

STM32C0116-DK: Problem with SPI + DMA at 24MBits/s

  • January 7, 2026
  • 2 replies
  • 114 views

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:

  • All clock to max (48MHz)
  • SPI: Full-Duplex Master, 8bits, Mode 01, DMA Tx + DMA Rx
    • Prescaler 2: BaudRate 24 MBits/s -> FAIL
    • Prescaler 4-Max: SUCCESS

This is the result with prescaler set to 4 (12 Mbits/s). (Pink: MISO, Blue: SCK), the data is correct.

LabGluon_1-1767800596768.png

With the Prescaler set to 2 (24MBits/s) (Pink: MISO, Blue: SCK). The clock does not even try (the pulse is 3us)

LabGluon_2-1767800694645.png

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? 

    This topic has been closed for replies.
    Best answer by TDK

    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.

    2 replies

    Super User
    January 7, 2026

    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...

     

    LabGluonAuthor
    Visitor II
    January 7, 2026

    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.

    LabGluon_0-1767802320546.png

     

    Super User
    January 7, 2026

    What you set the pin speed to ?

    -> Make sure pin speed is set to VERY_HIGH.

     

    TDKAnswer
    Super User
    January 7, 2026

    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.

    LabGluonAuthor
    Visitor II
    January 7, 2026

    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!