cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 DMA interrupt at the end of ADC conversion

mehmet.karakaya
Associate III
Posted on September 17, 2016 at 16:54

hello dear forum,

I try to DMA-ADC with my STM32F4

I want that at the end of DMA transfer

it stops conversion and gives an interrupt and so I can check the ADC result

I couldnot see an example at the STD library

please a tip how to adjust DMA for interrupt 

thank you

#stm32f4-dma-adc
3 REPLIES 3
Posted on September 17, 2016 at 22:37

The DMA can generate a TC interrupt when it completes a set of transfers. ie an EOC for all channels.

You can configure the DMA in circular mode so you only need to initialize it once.

If you config the ADC in non-continuous mode it will do the list of enumerated channel once every time you trigger it (via software, or timer).

For more continuous operation you might want to double the DMA buffer size and use the HT and TC interrupts to manage alternating halves of the buffer.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mehmet.karakaya
Associate III
Posted on September 18, 2016 at 12:26

Hello Clive , thank you

is this code OK with Interrupt handler how do I adjust this code to handle DMA1 channel 1 interrupt ?

void
DMA_STREAM_IRQHANDLER(
void
)
{
/* Test on DMA Stream Transfer Complete interrupt */
if
(DMA_GetITStatus(DMA_STREAM, DMA_IT_TCIF))
{
/* Clear DMA Stream Transfer Complete interrupt pending bit */
DMA_ClearITPendingBit(DMA_STREAM, DMA_IT_TCIF);

is this code OK for initializing ? how do I adjust this code to init DMA1 channel 1 interrupt ?

DMA_ITConfig(DMA_STREAM, DMA_IT_TC, ENABLE);
-------------------
NVIC_InitStructure.NVIC_IRQChannel = DMA_STREAM_IRQ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

Posted on September 18, 2016 at 14:40

The STM32F4 needs attention to the Stream used, and that impacts how it is cleared. The Channel is more of a configuration issue, associating what the DMA request source is.

void DMA2_Stream0_IRQHandler(void)
{
/* Test on DMA Stream Transfer Complete interrupt */
if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))
{
/* Clear DMA Stream Transfer Complete interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
// Add code here to process buffer
}
...
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..