cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with DMA config

ronan2
Associate II
Posted on October 10, 2010 at 16:46

Problem with DMA config

#dma-irq #dma-isr-interrupts
5 REPLIES 5
Posted on May 17, 2011 at 14:10

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ronan2
Associate II
Posted on May 17, 2011 at 14:10

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6ZW&d=%2Fa%2F0X0000000bqx%2FpqcMzd7bVXn7Q8c9TuWx45NofQGc_Vzdqd.DYoAkReA&asPdf=false
ronan2
Associate II
Posted on May 17, 2011 at 14:10

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,

Ronan

Posted on May 17, 2011 at 14:10

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);

  }

}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 17, 2011 at 14:10

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);

  }

}

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