Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > UART based buffer filling and reading via DMA

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



UART based buffer filling and reading via DMA
Moderator:
ANCY

Post Reply
Follow this topic



UART based buffer filling and reading via DMA

Meenz posted on 25 Apr 2011 11:12 PM PST
Member
10 Forum Posts

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




Re: UART based buffer filling and reading via DMA

Gautam Das posted on 25 Apr 2011 05:20 AM PST
Cypress Employee
742 Forum Posts

Hi meenz,

 

Are you using CyDMAChDisable/ CyDMAChDisable APIs?

 

 



Re: UART based buffer filling and reading via DMA

Meenz posted on 25 Apr 2011 05:50 AM PST
Member
10 Forum Posts

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



Re: UART based buffer filling and reading via DMA

Meenz posted on 25 Apr 2011 06:20 AM PST
Member
10 Forum Posts

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[i]);          


        }      


        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



Re: UART based buffer filling and reading via DMA

U2 posted on 28 Apr 2011 10:03 PM PST
Cypress Employee
589 Forum Posts

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






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20