cancel
Showing results for 
Search instead for 
Did you mean: 

ADC injected mode with GPDMA?

yang2
Associate III

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,

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4
yang2
Associate III

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

 

 

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

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

Hello,

We know that DMA can effectively reduce the CPU's load in handling data transfers.

That's correct, but in the case of injected channels, there is no data to transfer. As the data are stored in a dedicated register, just read it when you need it. This is the reason why DMA cannot be connected to injected channels.

Of course, this work only if you consume the data before it is overwritten by another conversion with the same channel. But if it is the case then you would probably face real time issue ...

Best Regards

Cedric