2016-12-15 07:14 AM
I would like to record signal peaks from an ADC to a DMA buffer.
I have this working in continuous and software triggered modes to circular buffers.
I have a adc watchdog interrupt working to detect a 'high signal'.
I am trying to put them together to record 'high' peaks in the signal to a buffer.
what i cant figure out is how to start the DMA on event for a ADC that is already running in continuous mode with interrupts for the high level watchdog.
in am use HAL libraries.
currently i have been starting the ADC with DMA with;
HAL_ADC_Start_DMA(&hadc1,(uint32_t*) &ADC_Data, 5000);
i know i can start ADC with interrupts for watchdog using;
HAL_ADC_Start_IT(&hadc1);
what do i need in my watchdog interrupt to start DMA transfer?
void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc)
{ if (__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_AWD1) != RESET) { //Start DMA here }}Additionally:
i don't need continuous DMA or a circular buffer.
I can have a fixed buffer size. Filling to the end and stopping is fine.
I can controlled ADC triggering rate with timer to give peak sampling rate and duration
Basically, i need to know what HAL_ADC_Start_DMA(&hadc1,(uint32_t*) &ADC_Data, 5000); does
in addition too what HAL_ADC_Start_IT(&hadc1); does; and put that in my watchdog interrupt handler.
Sorry i an really new to the STM32 world. Hope one of you gurus can help.
2017-09-15 10:05 PM
Thank you for your reply.
i was finally make it work.
what you gave as an options for callback are just callback which the ADC IRQHandler function should call.
that means you have to declare this inturrept on NVIC by us
i
ng :HAL_NVIC_SetPriority(ADC_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(ADC_IRQn);
as suggested earlier.
then at the IRQ file you have to have ADC_IRQHandler functiom which called for any type of ADC IRQ (cptr/outwindow).
can post full flow if needed
thank you.
2017-09-16 03:04 AM
On a generic STM32, I would run adc dma on a circular buffer and the watchdog interrupt used to snapshot the dma buffer pointer value. Then get interrupt when the sampling time is over, and finally sweep for the max value.
2017-09-17 08:40 PM
two posts ago I recommended the circ dma buffer and pointer sampling on both ends using awd interrupts. If you do it as you suggest, the awd enter interrupt might happened every near the dma complete interrupt. And you won't have many or maybe enough samples, so then you have to decide if you will go another loop around the buffer or maybe halfway.
The awd feature has multiple windows, so it seems a lot more simpler to setup one window for an 'enter' peak sample interrupt and a second for ''leave' peak sample interrupt. You end up with just the peak data, not extra data after the peak.