2019-03-20 07:38 PM
The base software was set up using CubeMX. On an STM32L433, I have the ADC configured to read 4 channels into a DMA. The sampling is ADC_SAMPLETIME_6CYCLES_5 for all channels. The DMA is set up for a WORD transfer into a buffer: uint32_t dmaBuffer[4];
and a callback is set up to copy the dma buffer to another buffer . The DMA is started with this:
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)dmaBuffer, 4);
This is the ADC setup parameters:
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.NbrOfConversion = 4;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
hadc1.Init.OversamplingMode = DISABLE;
And this is the DMA setup:
hdma_adc1.Instance = DMA1_Channel1;
hdma_adc1.Init.Request = DMA_REQUEST_0;
hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_adc1.Init.Mode = DMA_CIRCULAR;
hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
The callback runs, but just once. The data is correct for the voltages on the pins.
Why would it be doing this?
2019-03-21 06:36 AM
I have tried so many things and nothing works. Why does the ST video make it look like a "breeze"? Is there maybe an issue with the newest version of Cube?
Can any one can offer some insight as to what the problem might be, given the above settings? Either something obvious or a bug in CubeMX/HAL software? Someone from ST ????
2019-03-21 02:44 PM
My crystal cube says that this line
hadc1.Init.DMAContinuousRequests = DISABLE;
might be the culprit.
JW
2019-03-21 07:41 PM
hi jw,
tried that with no success. it is working thought, a bit unorthodox but I like this method. in the callback, after gather the required number of samples and copied into the averaging buffers, I use again HAL_ADC_Start_DMA(&hadc1, (uint32_t*)dmaBuffer, 4); and also set a completion flag.
I actually do this from an RTOS task and since it's a controllerd rate execution, I check the flag in the task. I'll most like change this to man event queue as this method is a bit barbaric (like HAL)
Anyhow, it works, and very nice sampling on the data, very good resolution.
i appreciate that you took the time to answer my post.