Skip to main content
Explorer
February 1, 2025
Question

STM32F030C8T6TR DMA

  • February 1, 2025
  • 5 replies
  • 1356 views

Greetings

I am using STM32F030C8T6TR for ADC on two channels IN1 & IN3. It works. However I wanted to add DMA. 

When trying to add DMA , It shows on two channels channel 1 and channel 2 , Though the datasheet mentions DMA is available for 5 channels. I can add DMA for channel 1 - Peripheral to memory. However when I try to add a DMA for another channel It shows error "No DMA available for this peripheral". 

I could add DMA for the above channels in Memory to memory mode.for the ADC though. Is this OK can It my understanding that when using ADC, peripheral to memory should be used. In which case I can add only one of the two channels - channel 1 or channel 2. 

How does this work ? will memory to memory on both channels work as expected ? 

or is this some kind of version related error ? I use STM32CubeIDE1.15.0 on windows 7. 

Thank you. 

 

    This topic has been closed for replies.

    5 replies

    Graduate
    February 1, 2025

    Please read the ADC description in Reference Manual. You only need one DMA channel for ADC, in peripheral to memory mode, programmed to transfer the number of item equal to the number of ADC channels being converter.For simple cases, it's convenient to setup ADC in continuous conversion mode and DMA in circular mode.

    SbagAuthor
    Explorer
    February 1, 2025

    Thank you for responding. 

     

    //Please read the ADC description in Reference Manual.// Read several times

     

    //You only need one DMA channel for ADC, in peripheral to memory mode, programmed to transfer the number of item equal to the number of ADC channels being converter.  // The datasheet doesn't specifically that only one channel needs to be added to DMA so that we can use it for other channels. What was more confusing is the way STMCube IDE behaves / displays. If only one channel needs to be added why it is displaying channel nos at all against ADC-> DMA ? Channel selector could be left un-enabled. Pls read page 17 , section 3.8 of the datasheet. It starts with //  5-channel... // plus the thrid para starting with // Each channel is ...... // 

     

    I wouldn't have posted here at all if the IDE do not show either of channel.   

     

    Graduate
    February 1, 2025

    And how many channels may service the ADC simultaneously according to RefMan? Hint: there is only one ADC conversion result register, also see Fig. 19 and Table 26. ;)

    SbagAuthor
    Explorer
    February 1, 2025

    Which refMan are you mentioning ? 

    Table 26 on the datasheet is for "Typical and maximum current consumption from the Vdda supply" Figure 19 on page 63 shows "TC and TTa I/O input characteristics" 

    It seems datasheet I am referring and the RefMan you are mentioning are different. 

     

     

    Super User
    February 1, 2025

    There are two different things: ADC channels (inputs) and DMA channels. The DMA controller has 2 DMA channels with can be triggered by the ADC. The number of ADC channels is totally independent of that. All selected ADC channels will be typically sampled in one circular sequence. Think of 2 audio channels L and R that will be sampled in order L R L R .... and streamed to a common memory buffer by one DMA channel.

    hth

    KnarfB

    SbagAuthor
    Explorer
    February 1, 2025

    //There are two different things: ADC channels (inputs) and DMA channels// Naturally - Understood. 

    So how do one set DMA for ADC channel 1 and Channel 3 on this microcontroller ?

    from the Analog -> ADC -> DMA Settings I get 

    DMA request - Channel - Direction - Priority

    I can select ADC for DMA request

    I get option to select Channel 1 or Channel 2 Under Channel 

    I can select Peripheral to memory under direction

    I can select Low to Very High , any of the 4 options under priority 

     

    Under DMA settings 

    I can select Normal or Circular for Mode

    Check box for Incremental Address is locked

    Check box Memory is checked 

    Data width under Peripheral is Half word 

    Under memory is half width 

     

     

    should I configure DMA under System Core ? 

    Inside DMA under System Core 

    I get only Memory to memory for DMA request 

    Under Channel , I can select any of the 5 channels

    Under direction only memory to memory could be selected

    I can select any of the 4 options under priority 

     

    DMA added under ADC is displayed automatically on this screen too. as Peripheral to memory and channel as DMA1  channel 1. wich i can change to DMA 1 channel 2 

     

    Do I need the to entries DMA setting under system core memory to memory - DMA 1 channel 1 & DMA 1 channel 3 

     

     

    Graduate
    February 2, 2025

    Once again. Start by READING the Reference Manual for your MCU - you can't do anything reasonable without basic understanding of peripheral operation. You need ONLY ONE DMA  channel for ADC, no matter how many ADC inputs are sampled in a sequence. The most common use is to setup the DMA so that it copies N conversion results from ADC DR to N 16-bit word buffer in memory. Set the DMA in circular mode, so that you don't need to reprogram it anymore.

    SbagAuthor
    Explorer
    February 2, 2025

    Thank you, 

    Unfortunately my STMLink v2 smoked yesterday evening. It will take about a week for new one to arrive. I shall post after I get the new one. 

    Graduate
    February 2, 2025

    It wasn't ST-Link me thinks. And ST-Link 2 is long gone/unavailable. ;)

    SbagAuthor
    Explorer
    February 10, 2025

    Hello guys, 

    Got it working . Both Polling Method and DMA too.  

    Strangely , I could debug too using the obsolute cheap ST-Link V2 with openCD. It never used to work. It took some pretty good effort to make it work. .   

    Thanks a lot for all your participation.