8 Replies Latest reply on Feb 22, 2019 7:13 AM by user_58361

    How to link SAR ADC to VDAC using DMA

    user_58361

      Dear community,

       

      As already discussed in DMA Wizard prohibits linking 8-bit SAR ADC to 8-bit VDAC there is an option to change the DMA capability file of the SAR ADC to obtain 1 byte burst. With the help of the component author guide and some videos on how to create component project libraries, I am still none the wiser on how to change the DMA capabilities of the SAR ADC. Would someone be so kind as to point me in the right direction, such that I can use a SAR ADC in combination with a VDAC? The project I want to test this with has been added.

       

      I thank you very much in advance.

       

      Jim

        • 1. Re: How to link SAR ADC to VDAC using DMA
          BoTa_264741

          Jim,

          I believe that using ADC address ADC_SAR_WRK0_REG (more precise ADC_SAR_1_WRK0_REG if the name of the ADC is ADC_SAR_1) should work. Change amount of transfer bytes to 1.

          No need to use a DMA 'wisard' or to modify DMA capability.

          /odissey1

           

          • 2. Re: How to link SAR ADC to VDAC using DMA
            user_58361

            /odissey1,

             

            Thank you for your response. I do not completely follow what you mean. Am I supposed to configure the DMA on my own? Or just modify the bytes per burst to 1 and ignore the warning in the DMA wizard?

             

            If I ignore the warning, and set bytes per burst to 1, I get the following:

            /* Defines for DMA_SAR2VDAC */

            #define DMA_SAR2VDAC_BYTES_PER_BURST 1

            #define DMA_SAR2VDAC_REQUEST_PER_BURST 1

            #define DMA_SAR2VDAC_SRC_BASE (CYDEV_PERIPH_BASE)

            #define DMA_SAR2VDAC_DST_BASE (CYDEV_PERIPH_BASE)

             

            /* Variable declarations for DMA_SAR2VDAC */

            /* Move these variable declarations to the top of the function */

            uint8 DMA_SAR2VDAC_Chan;

            uint8 DMA_SAR2VDAC_TD[1];

             

            /* DMA Configuration for DMA_SAR2VDAC */

            DMA_SAR2VDAC_Chan = DMA_SAR2VDAC_DmaInitialize(DMA_SAR2VDAC_BYTES_PER_BURST, DMA_SAR2VDAC_REQUEST_PER_BURST,

                HI16(DMA_SAR2VDAC_SRC_BASE), HI16(DMA_SAR2VDAC_DST_BASE));

            DMA_SAR2VDAC_TD[0] = CyDmaTdAllocate();

            CyDmaTdSetConfiguration(DMA_SAR2VDAC_TD[0], 1, DMA_SAR2VDAC_TD[0], 0);

            CyDmaTdSetAddress(DMA_SAR2VDAC_TD[0], LO16((uint32)ADC_SAR_1_SAR_WRK0_PTR), LO16((uint32)VDAC8_1_Data_PTR));

            CyDmaChSetInitialTd(DMA_SAR2VDAC_Chan, DMA_SAR2VDAC_TD[0]);

            CyDmaChEnable(DMA_SAR2VDAC_Chan, 1);

             

            If I set ADC_SAR_1_SAR_WRK0_PTR to ADC_SAR_1_SAR_WRK0_REG, it should work if I understood you correctly. If not, please let me know. For today, I will not be in the lab again to test this. Tomorrow, I will try if I can get an ouput on P0_6.

             

            Jim

            • 3. Re: How to link SAR ADC to VDAC using DMA
              user_58361

              Dear community,

               

              Unfortunately, the suggestion of /odissey1 did not work out as I would have hoped. Hence, I am still looking for a solution to drive the 8bit VDAC with a 8bit SAR ADC. Does anyone have an other idea in order to get the application working?

               

              With kind regards,

               

              Jim

              • 4. Re: How to link SAR ADC to VDAC using DMA
                BoTa_264741

                Jim,

                Attached is a demo project

                /odissey1

                 

                 

                ADC_SAR-DMA-VDAC_01a.png

                ADC_SAR-DMA-VDAC_01b.png

                • 5. Re: How to link SAR ADC to VDAC using DMA
                  user_58361

                  /odissey1,

                   

                  Many thanks! This helps me very much in continuing my internship.

                   

                  With kind regards,

                   

                  Jim

                  • 6. Re: How to link SAR ADC to VDAC using DMA
                    user_58361

                    /odissey1,

                     

                    One thing that I have noticed once I did some further testing with this is that it seems that the input for the SAR is not the same as the output of the VDAC. For the 4V VDAC range, the output is 2x the input of the SAR. For the 1V VDAC range, the output is half of the SAR input.

                     

                    For this I have no answer yet and I am not sure if this is due to the way the DMA is writing data from the SAR to the VDAC. Do you perhaps know how this occurs?

                     

                    With kind regards,

                     

                    Jim

                    • 7. Re: How to link SAR ADC to VDAC using DMA
                      BoTa_264741

                      Jim,

                      DMA transfers full-scale digital 8-bit from ADC to VDAC.

                      Full-scale analog ranges are: ADC input 0-2V, VDAC output either 0-1V or

                      0-4V, which are obviously do not match.

                      You can bring VDAC output to 2V scale by few ways: (a) set output scale to

                      4V and use /2 resistor divider; (b) set VDAC output scale to 1V and buffer

                      it using PGA with gain of 2; (c) set ADC scale to O-4V).

                       

                      Typically this is not the issue, because some math is used between ADC and

                      VDAC and feedback path has it's own gain. It is hard to advise further, as

                      I don't know your application and converting ADC voltage to DAC 1:1 seems

                      having only educational value.

                      /odissey1

                       

                       

                       

                      On Fri, Feb 22, 2019, 5:52 AM j.m.v.dam_3854156 <

                      • 8. Re: How to link SAR ADC to VDAC using DMA
                        user_58361

                        /odissey1,

                         

                        That clarifies a lot! Quite logical explanation, so thank you for explaining.

                         

                        My application is to develop a bidirectional optimal trajectory control algorithm for a series-resonant converter, quite a mouthfull, but a very interesting topic. This is for my internship at the Eindhoven University of Technology within the Power Electronics deparment of Electrical Engineering. The main result is to find out how interesting it is to implement control algorithms using, for instance, the PSoC 5LP prototyping kit. Nonetheless, I am figuring out how a voltage measurement can be converted from analog to digital, after which some calculations are performed for a reference voltage. This reference voltage has to be compared to the voltage that has initially been converted from analog to digital. Therefore, I am looking into ADC and VDAC, but with the scaling in mind, I am quite sure that I can find a solution that will work for me.

                         

                        Again, many thanks!

                         

                        Jim