Skip to main content
yang2
Associate III
September 27, 2024
Solved

ADC injected mode with GPDMA?

  • September 27, 2024
  • 1 reply
  • 1165 views

Dear Sir, 

I am developing a motor control system with STM32H563, and I need to measure the 3 phase current by ADC.

I would like to configure the ADC1 with injected mode and transfer the ADC data via GPDMA.

I can't find the information from reference manual and no appropriated API in HAL Liibrary.

 

The DMA is only availabe with regular mode. 

 

Does anyone how to use injected mode with GPDMA? Is it feasible?

 

 

Best Regards,

 

    Best answer by cedric H

    Hi @yang2,

    What you describe looks similar to what we do in our MCSDK. 

    Have you already looked at it? STM32H5 is supported in our latest MCSDK 6.3.1 

    To answer your question, the best way to achieve this is to use injected mode for the currents. No need to have a DMA as each converted value is stored in a dedicated register, and use regular for Voltage and Temperature. It can be done asynchronously with current sensing as injected conversions will interrupt ongoing regular conversion.

    Hope it helps.

    Cedric

    1 reply

    yang2
    yang2Author
    Associate III
    September 27, 2024

    I have noticed a past post,

    https://community.st.com/t5/stm32-mcus-products/stm32f407vg-adc-injected-channel-with-dma/td-p/652531

    and the ST Employee had response "DMA can't handle with injected mode" .

     

    So, I have another questions.

    In my system, I need to measure the current(x3), voltage(x1), temperature(x4), and there are all connect with ADC1.

    However, the sample timming and period is different. For instance, the current must be sample by PWM frequency(16KHz) and while at PWM overflow event

    The other signals, such as temperatures, just need to be sample under 1kHz.

     

    Can I configure the ADC1 for different trigger source or sample frequency to different channels?

    Current(x3)  at 16KHz and  at overflow event.

    Voltage(x1) at 1KHz

    Temperature(x4) at 1KHz

     

     

    cedric H
    cedric HBest answer
    Technical Moderator
    September 27, 2024

    Hi @yang2,

    What you describe looks similar to what we do in our MCSDK. 

    Have you already looked at it? STM32H5 is supported in our latest MCSDK 6.3.1 

    To answer your question, the best way to achieve this is to use injected mode for the currents. No need to have a DMA as each converted value is stored in a dedicated register, and use regular for Voltage and Temperature. It can be done asynchronously with current sensing as injected conversions will interrupt ongoing regular conversion.

    Hope it helps.

    Cedric

    yang2
    yang2Author
    Associate III
    September 30, 2024

    Dear cedric H, 

    Thanks your reply. 

    Yes, I have already reviewed the ADC configuration in MCSDK and know that it uses injected mode to measure current, while regular mode is used to measure other secondary priority values (DC bus, temperature).
    However, I find that it does not make use of GPDMA. We know that DMA can effectively reduce the CPU's load in handling data transfers.
    That’s why I am considering adding the GPDMA functionality base on the MCSDK configuration to make use of it. I want to make the most of the resources on the STM32H5, allowing the CPU to focus more on handling other application layer tasks.

    Best Regards,

    Fan