2017-01-20 10:17 PM
2017-01-20 11:39 PM
Did you set your DMA stream to circular?
And your adc to continuous?
2017-01-21 01:30 AM
Yes I had set to circular, and ADC set to continuous.
2017-01-23 08:46 AM
Your file main.c looks correct, can you send also the file stm32XXxx_hal_msp.c ?
Can you also attach the CubeMX file '.ioc' ?
2017-01-23 06:08 PM
Thanks Philippe,
Attached file is my current source code with .ioc file.
https://drive.google.com/open?id=0Bwq94iD4_g4ycU1kWEJoal9JZXc
2017-01-25 05:56 AM
I have tested your code, the ADC and DMA are working correctly: buffer is updated indefinitely with ADC conversion data.
But there is a problem of overhead situation in IRQ handler: the buffer size is small (array of 4 addresses) and the ADC is configured to convert at high frequency.
The DMA half-transfer and DMA transfer complete interruptions will occur too frequently, the CPU is overloaded with these interruptions to handle.With your settings, ADC conversion frequency is:
=> Every 1.56us, CPU must handle 2 DMA interruptions
To reduce the ADC conversion frequency, you can increase sampling time.
ChangesConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
tosConfig.SamplingTime = ADC_SAMPLETIME_181CYCLES_5;
If you want to keep ADC conversions at high frequency with DMA transfer, either with DMA optimized interruption handling or without DMA interruptions (use case to pick ADC conversion data in buffer at will), you should use LL driver to customize the ADC and DMA configuration to your need.LL driver for STM32F3 will be managed soon by CubeMX (in Project Settings -> Advanced Settings -> Driver). In the meantime, LL driver is in STM32F3 FW package and can be downloaded here:http://www.st.com/en/embedded-software/stm32cubef3.html
.Then, you can find an example here: STM32Cube_FW_F3_V1.7.0\Projects\STM32F334R8-Nucleo\Examples_LL\ADC\ADC_MultiChannelSingleConversion\
Something else, not related to your issue:
You are using only 1 ADC (therefore in single mode, not in multimode). This configuration is missing, you should add
multimode.Mode = ADC_MODE_INDEPENDENT;
before
multimode.DMAAccessMode = ADC_DMAACCESSMODE_12_10_BITS;
multimode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_1CYCLE;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
Error_Handler();
}
(and you can also remove configuration of 'multimode.DMAAccessMode' and 'multimode.TwoSamplingDelay')