2010-10-10 07:46 AM
Problem with DMA config
#dma-irq #dma-isr-interrupts2011-05-17 05:10 AM
Well, you should probably do the NVIC_Init() first so you don't induce a race condition.
How does it ''crash''? It you don't service the interrupt properly it will get stuck in the interrupt state and not run any user code. You need to post a more complete exemplar.2011-05-17 05:10 AM
2011-05-17 05:10 AM
Hi Clive,
Really appreciate the input, steers me in the right direction. When you refer to DMA1_Channel5_IRQn() I prefer you mean the IRQ handler you outline ie void DMA1_Channel5_IRQHandler(void){}...sorry if I'm a little slow on this. Big gap to fill ;) I'm off to brush up on interrupts/subroutines. Thanks again, Ronan2011-05-17 05:10 AM
Ok, I'll take a look at this when I get a chance.
What do you have going on in DMA1_Channel5_IRQn()? I don't see code for that, you have to ensure that it's clearing pending interrupts that you are generating. Ditto with the SPI interrupt. From your symptoms I'm going to guess that either the interrupts are left pending, or you get a hard fault from touching the wrong memory. Something along these lines is required, plus whatever action/chaining you want to implement. void DMA1_Channel5_IRQHandler(void) /* this is for the 2.x library, for 3.x DMA1_Channel5_IRQn */ { /* Test on DMA1 Channel5 Transfer Complete interrupt */ if(DMA_GetITStatus(DMA1_IT_TC5)) { /* Clear DMA1 Channel5 Half Transfer, Transfer Complete and Global interrupt pending bits */ DMA_ClearITPendingBit(DMA1_IT_GL5); } /* Test on DMA1 Channel5 Half Transfer interrupt */ if(DMA_GetITStatus(DMA1_IT_HT5)) { /* Clear DMA1 Channel5 Half Transfer */ DMA_ClearITPendingBit(DMA1_IT_HT5); } }2011-05-17 05:10 AM
I'm using the pre-CMSIS library, but in the newer one you typically put the subroutine in stm32f10x_it.c
void DMA1_Channel5_IRQHandler(void) { your handler code } Attached (see paper clip, upper right) is the one from the DMA example ST supplies with the VL Discovery board. Most of the tool chains also have assorted example code. /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /******************************************************************************/ /** * @brief This function handles DMA1 Channel 6 interrupt request. * @param None * @retval None */ void DMA1_Channel6_IRQHandler(void) { /* Test on DMA1 Channel6 Transfer Complete interrupt */ if(DMA_GetITStatus(DMA1_IT_TC6)) { /* Get Current Data Counter value after complete transfer */ CurrDataCounterEnd = DMA_GetCurrDataCounter(DMA1_Channel6); /* Clear DMA1 Channel6 Half Transfer, Transfer Complete and Global interrupt pending bits */ DMA_ClearITPendingBit(DMA1_IT_GL6); } }