How to use properly ADC to DMA, HAL_ADC_Start_DMA(&hadc1, (uint32_t*)array, 1000);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-20 12:12 PM
I want to make 1000 scans, I have the adc running at 1.5 Msps, 12 bit resolution on 180 Mhz Nucelo board.
when I put HAL_ADC_Start_DMA(&hadc1, (uint32_t*)array, 1000); in main(); it would run only once
I want a continues scan, it seams to be doing just that in while(); loop
but I think that I need some delay like
while();
{
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)array, 1000);
HAL_Delay(1);
}
Fist question does it indeed take 1000 scans and puts in the array[1000];
Second how to properly implement it so I have access to data in array all the time.
And it look like I have to declare
uint32_t array[1000];
anything else like uint16_t array[1000]; wouldn't work
I am new to this and I do not understand fully all the code, what they do.
- Labels:
-
ADC
-
DMA
-
STM32Cube MCU Packages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-20 1:42 PM
- when using data arrays accessed by DMA, you need a #pragma at the declaration line to tell the linker it is 32 bit aligned address. Compiler dependent. If don't know, check USB example, it's using DMA so you'll find the answer to the question
- Double the buffer size and get a DMA half transfer interrupt so you can process your first 1000 samples while the next 1000 are bering processed and you reprogram the DMA to loop back. (double buffering). No delay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-20 3:04 PM
would you know if it is indeed 1.5 Msps, I am using Cube MX and it says there 12 bit resolution takes 15 clock cycles
But at the bottom there is also sampling time, it is a little confusing I have sampling time 3 cycles.
would the actual speed be 15 + 3 clock cycles. or it is independent.
or the sampling time is time to get the adc data already sitting in the buffer.
the highest speed is supposed to be 2.5 Msps but for lowest resolution 6 bits
