2024-03-28 01:18 PM - edited 2024-03-28 01:20 PM
I am using STM32F407G.
I am attaching a main.c (that use DMA) that reads simultaneously the voltage coming from 3 potentiometers connected to 3 channels of ADC.
In the code, if you try to change "volatile uint16_t adc_value[3]" to "volatile uint32_t adc_value[3]" this is what happens:
Huge values (above the upper limit 2^n with n = num bits) are displayed.
I don't understand why this happens.
"adc_value" is the number read by the ADC while "adc_CH1_value_volt" is converted to volt (of the 1° channel)
Solved! Go to Solution.
2024-03-28 02:28 PM
>I don't understand why this happens.
Because the ADC values are moved by the DMA, and the setup code for the DMA is not shown. That code defines the bit size of the values. So DMA does not know that you've changed the values type to 32 bit.
2024-03-28 02:19 PM
>>I don't understand why this happens
Are you sure the project completely rebuilt properly?
2024-03-28 02:28 PM
>I don't understand why this happens.
Because the ADC values are moved by the DMA, and the setup code for the DMA is not shown. That code defines the bit size of the values. So DMA does not know that you've changed the values type to 32 bit.
2024-03-28 02:31 PM
You are right! Now that I think about it, in the .ioc file in the dma settings I selected Half Word ... I'll try changing it to word and it should also work with 32 bit!