UART based buffer filling and reading via DMA

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

I am relatively new to PSoc. I am developing an appliaction wherein i have a circular buffer of depth 16K. So I am using a DMA channel with 4 TD's chained together and looped back. I am continuously filling this memory with data from UART. Basically I am reading a file from UART, storing it in a buffer(something like a FIFO) and whenever DMA requires, it fetches a data from this memory and outputs to VDAC. A Timer is used to generate pulse for DMA drq.

   

As a first step in this application, After one whole file has been read by UART and output to VDAC. I use DMA_DmaRelease() to stop DMA operation and exit. This works perfectly even for file sizes of more than 64KB.

   

The next step was that after one complete file has been read by UART and transmitted to VDAC by DMA, I need to suspend every operation and start the same process with another file. To achieve this, following are the steps followed

   

- At end of file, call DMA_DMARelease()

   

- Free all TD's allocated for that fle

   

- Free the Channel and stop the Timer (Timer_Stop())

   

- Fill the circular buffer (16K) data ) with new data

   

- Call DMA_DmaInitialise() again, allocate new TD's and start the Timer again.

   

What is occuring is that the initial portion of data after every DMARelease is incorrect but later it becomes allright. This occurs at the end of each file to be read. I have also tried the follwiwing

   

- Call CyDmaChSetRequest(channel,CPU_TERM_CHAIN) at end of file.

   

- Fill the circular buffer (16K) data ) with new data

   

- Call DmaEnable()

   

 

   

Even the above sequence did not worl correctly.Could you tell me waht the problem could be.

   

Regards

   

Meenz

   

 

   

 

   

Could you help me with this

   

 

   

Regards

   

meenz

0 Likes
4 Replies
Anonymous
Not applicable

Hi meenz,

   

 

   

Are you using CyDMAChDisable/ CyDMAChDisable APIs?

0 Likes
Anonymous
Not applicable

Hi,

   

I had tried using CyDmaChDisable(channel) also and the result was similar.

   

Is there some delay associated with the DMA function  calls(is it not completely blocking).

   

Could you suggest the sequence of steps I should carry out to release the DMA channel and initialise a new one

   

 

   

Regards

   

Meenz

0 Likes
Anonymous
Not applicable

The code snippet looks like this

   

for(;;){

   

while(eof==0){

   

   if(flag==1 ){
        DMA_DmaRelease();         

   


        VDAC8_Stop();       

   

        eof=1;

   


         for(i=0;i<NUM_TD;i++){

   


            CyDmaTdFree(td);          

   


        }      

   


        CyDmaChFree(channel);

   


        // CyDmaChSetRequest(channel,CPU_TERM_CHAIN);         

   

         Timer_Stop();

   


          break;          
      }      

   

      else{

   

       ......

   

     }

   

  }

   

  if(eof=1){

   

           initialise_dma();   //(Fill buffer-> Dma Initilaize-> td allocate->, td set config->td set address ->

   

                                                                                                   //set initaltd -> dma channel enable )

   

         Timer_Start();

   


            VDAC8_Start();       

   


          eof=0;

   

  }

   

}

   

 

   

Regards

   

Meenz

0 Likes
Anonymous
Not applicable

Meenz, Can you attach the project. So that we can see the topdesign as well. 

0 Likes