Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 6 months ago.
I am using DMA ADC (HAL) and only get half of the values of the buffer
Hi,
I am programming an STM32F767ZI in order to use the ADC with DMA. Even though I'm writting the code with HAL libraries, I am using the Mbed compiler and the Mbed API.
Now I wrote a code that uses the DMA in order to get 2048 samples with the ADC and then calls the callback function. The problem is that when I try to access to the buffer, I find that only the even positions of the buffer are filled:
ADC_value[0] = value
ADC_value[1] = 0
ADC_value[2] = value
ADC_value[3] = 0
so on.
The configuration of the ADC is the following: (Actually the code configuration is from the STM32Cube examples)
And this is the DMA configuration:
The callback function:
Do you know what this can happen? I guess is something about the configuration but I do not find out :(
If you need more information about the code, tell me.
Thank you.
1 Answer
6 years, 6 months ago.
I initialized the buffer with 16 bits, but the DMA accepts 32. So when I move through the buffer, each index moves 16 bits. Then if you want to go to the next value of the ADC you have to move twice (32 bits in total).
If you initialize the buffer with 32 bits instead of 16 bits, you only have to move one index to get the next value.
Assigned to
6 years, 6 months ago.This means that the question has been accepted and is being worked on.
Ok, I think I know why this happens. I initialize the buffer with 32 bits and the DMA uses the first 16 bits and the other 16 are empty, then for the next sample you have to move two times in the memory.
posted by Sergi Hernández 19 May 2018