cancel
Showing results for 
Search instead for 
Did you mean: 

DMA normal buffer

sanjib
Associate III
Posted on March 13, 2015 at 14:50

Hi

I have attached a piece of code in which DMA is configures as circular buffer. I have configured a total buffer complete interrupt. when I get into the interrupt I want to change the BUFF_SIZE In data shet it is mentioned that before doing we have to disable the stream. I am doing exactly the same  but when I give a break point  in case 1 value it always posses the value in the BUFF_SIZE which is initialized before for e.g if BUFF_SIZE while prior initialization  is initialized to 240(value = 204)  anf the total buffer complete interrupt occurs in case 0 I initialized the BUFF_SIZE to 120(value = 103)  again but when I give a break point at value = DAC->DHR12R1. it always have the 204 ehich was initialized before what is the problem. One more thing is I want to configure as normal buffer not a circular one I mean I want to update the MOAR register too how to do that Please help

for your reference I have paste the code below

void DMA1_Stream5_IRQHandler(void)

{

  if(DMA_GetITStatus(DMA1_Stream5, DMA_IT_TCIF5))

    {

        DMA_ClearITPendingBit(DMA1_Stream5, DMA_IT_TCIF5);

    

          switch(index)

          {

          case 0:

              DMA1_Stream5->CR &= ~0x00000001;  // disabling the stream          

        

              DMA1_Stream5->M0AR = (uint32_t)& aSine12bit;

        

              DMA1_Stream5->NDTR = 160;           

             DMA1_Stream5->CR |= 0x00000001; //enabling the stream    

              index ++;

              break;

          case 1:

                       value = DAC->DHR12R1;

                       DMA1_Stream5->CR &= ~0x00000001;            // disabling the stream

              

                     DMA1_Stream5->M0AR = (uint32_t)& aSine12bit;

                     DMA1_Stream5->NDTR = 120;           

                      DMA1_Stream5->CR |= 0x00000001;     //enabling the stream

               

                   index ++;

                      break;

          case 2:

            

                 if ( flag_onetime == 1)

              {

               DMA1_Stream5->CR &= ~0x00000001;            // disabling the stream

               DMA1_Stream5->M0AR = (uint32_t)& aSine12bit;

               DMA1_Stream5->NDTR = 240;            /

               DMA1_Stream5->CR |= 0x00000001;     //enabling the stream

               flag_onetime = 0;

              }

          break;

          }

    }

  }

6 REPLIES 6
sanjib
Associate III
Posted on March 16, 2015 at 04:58

I have configured for normal buffer by making DMA_Mode_Normal and

DMA_FIFOMode_Disable .

The way I am using the Dma as follows Timer 5 ARR gets load by DMA1_Stream6

and Timer 5 triggered the DAC and DMA1_Stream5 loads the DAC value one by one as the TIM5 gets update through DMA1_Stream6. I think DAC is updating proper but timer 5 behaving abnormal first it loads the timer ticks value in from the first index after that it goes to the last . I confirmed this by reading the m = TIM5->ARR, n = DAC->DHR12R1. I have attached my code Please ave a look , what mistake I am doing

________________

Attachments :

TVG_v14.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I02i&d=%2Fa%2F0X0000000bSg%2FOQB9Vkjk51nelA6FxfeNz0pD9VMxRWdMfm.GpT6Fc60&asPdf=false
Posted on March 17, 2015 at 19:23

Not sure why it would skip first to last, unless it was mistriggering.

Would suggest you break it down into smaller, testable, pieces that concisely demonstrate the failure, or allow you to debug/understand what is going on.

You probably don't want to stand over it with a debugger, because these things aren't observable at a human time scale. Have the code monitor states internally and provide telemetry via buffered or logged output.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
sanjib
Associate III
Posted on March 23, 2015 at 13:24

I havee a created a simple test program DMA updating the clocks tics for tim 5 . Tim 5 triggers the DAC. DMA associated with DMA too loading the data from the look up table. here too behaving the same whether my configyuration of normal buffer is correct please check . I have attached the file.

________________

Attachments :

TVG_v14.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzwb&d=%2Fa%2F0X0000000bSe%2FJWa4Br8iJCZyA8wK1wu28YuFw_g9aGERfNp0DRQdIoU&asPdf=false
Posted on March 23, 2015 at 14:09

This is still awfully cluttered, I don't have the time/patience to unravel it to the core issue. Are you sure your method to disable/change/enable the DMA is workable?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
sanjib
Associate III
Posted on March 24, 2015 at 10:27

That's what it is mentioned in the reference manual to change the MOAR and NDTR register we have to disable the stream and enable it again.

Posted on March 24, 2015 at 18:05

Ok, try to demonstrate that it works, or how it works, in small example program with 100 lines or less.

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