1 2 Previous Next 28 Replies Latest reply on Nov 27, 2014 2:45 AM by userc_45282






      I’m trying to transfer data from ADC-SAR to UART using the DMA. For this I followed the Configuration showed in AN52705, but I’ve got this error:


       .\main.c: In function 'DMA_Config':


      .\main.c:83:36: error: 'ADC_SAR_1_WRK0_PTR' undeclared (first use in this function)


      Could anyone help me?


      Best regards






      Main + DMA configuration:




      #include <project.h>




      /* DMA Configuration constants for DMA_1 */


      #define DMA_1_BYTES_PER_BURST (1u)


      #define DMA_1_REQUEST_PER_BURST (1u)








      void DMA_Config(void);






      int main()
















          /* Place your initialization/startup code here (e.g. MyInst_Start()) */




          /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */






              /* Place your application code here. */














      void DMA_Config()




          /* Variable declarations for DMA_1 */


          uint8 DMA_1_Chan;


          uint8 DMA_1_TD[1] = {0};




          /* Iniitialize DMA channel */


          DMA_1_Chan = DMA_1_DmaInitialize(DMA_1_BYTES_PER_BURST, DMA_1_REQUEST_PER_BURST,


                                           HI16(DMA_1_SRC_BASE), HI16(DMA_1_DST_BASE));




          /* Allocate TD */


          DMA_1_TD[0] = CyDmaTdAllocate();




          /* TD configuration setting */


          CyDmaTdSetConfiguration(DMA_1_TD[0], 1u, DMA_INVALID_TD, DMA_1__TD_TERMOUT_EN);




          /* Set Source and Destination address */


          CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint16)ADC_SAR_1_WRK0_PTR), LO16((uint16)UART_TXDATA_REG));




          /* TD initialization */


          CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);




          /* Enable the DMA channel */


          CyDmaChEnable(DMA_1_Chan, 1u);



        • 1. Re: ADC_SAR DMA UART

          It is always advisable to post the complete project, so that we all can have a look at all of your settings. To do so, use
          Creator->File->Create Workspace Bundle (minimal)
          and attach the resulting file (do NOT use chrome, that still may not work).


          Probably you have made a typo regarding your Component's name.





          • 2. Re: ADC_SAR DMA UART

            Maybe datasheet is in error becuse in its table definition vs example furthere on in


            datasheet there is this typing -




            result = CY_GET_REG16( ADC_SAR_1_SAR_WRK0_PTR  );




            Regards, Dana.

            • 4. Re: ADC_SAR DMA UART

              thank you Dana for your hint, its working know :)
              i just posted the Project before I read your reply


              thank you Bob too



              • 5. Re: ADC_SAR DMA UART





                here I’m again,


                after successful compiling I implemented the Project on CY8KIT-001(PSoC 5LP), unfortunately I couldn’t get any data throw the UART-port when using the DMA.


                I just tested the communication throw UART by sending the ADC-data without DMA und it works.


                Could someone take a look at it, that would be nice?


                Best regards



                • 6. Re: ADC_SAR DMA UART

                       I tried to use the DMA wizard as described here (Page 32)but the UART didn’t appear in the “Destination” field. Maybe I have to activate the UART to be reached by DMA ??

                  • 7. Re: ADC_SAR DMA UART

                    In CyDmaTdSetConfiguration() you specified DMA_INVALID_TD as the next TD, I think you should use the TD[0] to transfer multiple bytes and not only one. Additionally i would set SAR-bits to 8.


                    You will get a maximum of about 10000 bytes/second over the UART line, but the SAR delivers more samples, you must find a solution for that problem.





                    • 8. Re: ADC_SAR DMA UART

                           Thanks Bob, I’ll try it on Monday and give a feedback




                      Actually, for further processing on a PC I want to transfer the data with up to 400KSps. But I think it’ll not work as I wish. So i’ll try to implement the data processing on chip, eg. FFT or maybe use another interface.


                      I’m a beginner in PSOC and this project becomes complicated but still interesting  :)



                      • 9. Re: ADC_SAR DMA UART

                        You m ight want to file a CASE to solve this using full res of


                        SAR. Looking at forum no one seems to have done this yet.


                        And post back the solution for others.








                        To create a technical case at Cypress -








                        “Technical Support”


                        “Create a Case”




                        You have to be registered on Cypress web site first.




                        Regards, Dana.

                        • 10. Re: ADC_SAR DMA UART





                          It still doesn’t work…


                          I could read the nrq-Signal of the DMA with a oscilloscope out, it is pulses with the frequency of 857143Hz which is the Sample rate of the ADC, that means, the samples are written in the memory (register of UART) but not transferred out.


                          I found this on PsocDevelopper,  it seems to be a similar problem like mine but somehow I couldn’t open the zip-file. Besides is it you Bob and Dana in this conversation?






                          Ps. I filed a case about “Transmit High-Rate ADC_Samples through UART” and soon I’ll post the/a solution

                          • 11. Re: ADC_SAR DMA UART

                            *                    I found this on PsocDevelopper....

                            • 12. Re: ADC_SAR DMA UART

                              Maybe I should reread thread, but looking at latest posted


                              project -




                              1) Your ADC is set for 1M SPS, 8 bits, so thats 8 Mbyte/sec or


                              8 Mbits/sec, + some overhead for EOC and read and DMA.




                              2) Your UART is set to 115K bits/sec, or ~ 14 Kbytes/sec.




                              In short you are producing far more data that the UART can handle.




                              Try reversing the rates, eg slow SAR down to its min of 74 K SPS or use


                              a trigger for conversion, to get rate down << UART, and thens ee if data


                              stream starts making sense. Or average enough samples to get rate <<






                              Regards, Dana.

                              • 13. Re: ADC_SAR DMA UART

                                Correct this -




                                1) Your ADC is set for 1M SPS, 8 bits, so thats 8 Mbyte/sec or


                                8 Mbits/sec, + some overhead for EOC and read and DMA.




                                to this -




                                1) Your ADC is set for 1M SPS, 8 bits, so thats 1 Mbyte/sec or


                                8 Mbits/sec, + some overhead for EOC and read and DMA.

                                • 14. Re: ADC_SAR DMA UART



                                  You have different choices based on your environment or your needs:


                                  You may sample data with a high rate for a short time, buffer the data and then transmit the chunk over the UART.


                                  You may setup a timer at 400kHz, set your SAR for single conversion and trigger each conversion. At eoc get and transmit the result. This method can come near the availlable MIPs of the core, so using DMA will free some of the needed instructions.





                                  1 2 Previous Next