14 Replies Latest reply on Mar 17, 2017 9:27 PM by AlVa_264671

    Locate array in SRAM


      Hi everyone


      I'm trying to get working a project  which transfer data from SRAM  Buffera[166] to DFB  and DFB to  SRAM  Bufferb[166] using two DMA components.


      I would need some help to set the above mentioned buffers at address 0x20000000  and 0x2000014E.


       Using   int16 myVar[166] _at_ 0x20000000  produce compiler error.


      Thank you very much for any help.

        • 1. Re: Locate array in SRAM

          There is no need to set the address of the buffer, just retrieve the address the compiler gave it by


          int16 * Bufferb[166];


          void * Baddress = Bufferb;





          • 2. Re: Locate array in SRAM

            Hi Bob


            Thank you for your answer.
            Really I cannot get working this project even with your previous suggestion.
            That's why I am posting it.
            This is my first time using DMA.


            This project is about get RMS values for AC main through a 120/12 v transformer with a resistor divider to get 1vpp.
            What I am posting you is just the sampling process and the necessary DMA transfers to get the Buffer1's data filtered after DFB on Buffer2.
            I'm checking the Buffer1 by using excel spreadsheet and the debugger to verify I get the sin wave and it works.
            I Cannot do the same with Buffer2 because the Dma Transfer doesn't work.


            I do not have a deep knowledge about pointers but I understand that you define a void pointer and assign it &Buffer1


            int16 * Buffer1[166];


            void * Baddress = Buffer1;


            This generate an  compiler error when I am using Buffer1 to store sampling data from the delta sigma.


            On the other hand how to relate the fact that he compiler assings the address to both buffers with the followings statements from the DMA component data sheet:


            "PSoC 5LP SRAM Access
            In PSoC 5LP, the DMA cannot access SRAM from 0x1FFF8000 to 0x1FFFFFFF, but it can access the same memory at 0x20008000 to 0x2000FFFF.


            The CPU accesses:
            0x1FFF8000 - 0x1FFFFFFF C-BUS 32KB
            0x20000000 - 0x20007FFF S-BUS 32KB


            The DMA accesses:
            0x20000000 - 0x20007FFF S-BUS 32KB
            0x20008000 - 0x2000FFFF C-BUS 32KB






            Thank you very much for your time.



            • 3. Re: Locate array in SRAM

              You can look into this code example for help for working with Del-Sigma ADC,DFB and DMA-



              • 4. Re: Locate array in SRAM

                 I would suggest a different way:


                Transfer via DMA directly from ADC to filter, no intermediate buffer needed. Use ADC eoc signal to trigger DMA.


                You'll need to move the uint8 DMA_2_Chan; and uint8 DMA_2_TD[1]; to global area, so you can re-enable DMA after a complete cycle.


                In your interrupt handler




                will the above line not clear the interrupt, read the Timer_ReadStatusRegister() instead.





                • 5. Re: Locate array in SRAM

                  Hi Bob


                  Thank you very much, I will try your approach.



                  • 6. Re: Locate array in SRAM



                    for DelSig_ADC-DMA-DFB example see this link:






                    And for for full DelSig_ADC-DMA-DFB-DMA-VDAC this video



                    • 7. Re: Locate array in SRAM

                      Hi oddisey1


                      Thank you very much.


                      Very kind of you.


                      Alex 101

                      • 8. Re: Locate array in SRAM

                        Hi Bob and  oddisey1


                        I have taken both of  you guys  suggestions and I changed the project's approach based on that.


                        I cannot get the project working yet.


                        I can see the EOC signal with the scope and have the correct frequency, but the FilterDone flag never get true.


                        I attached a new bundle and a Flow diagram.


                        Thank you very much both of you in advance.

                        • 9. Re: Locate array in SRAM

                          Your ADC is 16 bit wide, but DMA is set up for 8 bits. Could be the error.





                          • 10. Re: Locate array in SRAM

                            Hi Bob


                            Thank you for your answer


                            I cannot understand your last answer,  The DMA_1  is set up for 2 bytes for burst and each burst require a request.


                            /* Defines for DMA_1 */
                            #define DMA_1_BYTES_PER_BURST 2
                            #define DMA_1_REQUEST_PER_BURST 1
                            #define DMA_1_SRC_BASE (CYDEV_PERIPH_BASE)
                            #define DMA_1_DST_BASE (CYDEV_PERIPH_BASE)




                            void ConfigDma1(void){


                            /* DMA Configuration for DMA_1 */
                            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));


                            DMA_1_TD[0] = CyDmaTdAllocate();




                            CyDmaTdSetConfiguration(DMA_1_TD[0] , 2u,   DMA_1_TD[0], 0u);




                            CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)ADC_DelSig_1_DEC_SAMP_PTR), LO16((uint32)Filter_STAGEA_PTR));


                            CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);




                            Thank you Bob

                            • 11. Re: Locate array in SRAM

                              ADC_DelSig_1_DEC_SAMP_PTR is a pointer to an 8-bit register and Filter_STAGEA_PTR as well.





                              • 12. Re: Locate array in SRAM



                                Setting aside issue with DMA setting for ADC-to-Filter transfer, I believe that the Digital Filter on the schematic (attached) is completely unnecessary. Instead,  ADC data should be digitized and transfered to RAM as-is. The whole point of measuring RMS is detecting the "imperfections" of the AC signal. Otherwise, simple rectification of sine or peak detection would suffice, which is much easier todo. Digital filter cuts-off voltage spikes, distorts original wave and adds phase shift, killing the whole idea of RMS calculation. Same applies to noise filtering on the analog front end.        


                                For DelSig_ADC-DMA-Filter to work I believe that the "coherency" and "alignment" settings of DelSig_ADC should be set as shown (for detail see project links in post #7)






                                • 13. Re: Locate array in SRAM

                                  Hi Dear odissey1


                                  Thank you so much for helping me.


                                  Yours commentaries are very valuable for me and they let me realize that I wasn't on a right track with this project.


                                  I posted  this project as part of the main one, I mean this is about to a test  for PSoC  5LP for measuring a low level voltage through Delta sigma ADC for posterior processing of the samples taken. This low level voltage comes out from a CT sensor for measure the amps used for Air Conditioner(A/C) unit compressors and fan motors.  Maybe you know that a A/Cpackage unit like those you can install on roof have up to 2 compressors and up to 3 fan motors. There are a lot of ac loads switching on and off very frequently inside of the sheet metal enclosure. Because of that I am using an active LPF in the signal path before drive the ADC, even to avoid saturate the ADC input range.  


                                  I understand that the Delta Sigma spread the noise over a wide range of frequencies and lowering the noise on the band of interest, so I put a DFB with the intention of improve the SNR when I have voltage level near 100 mvpp, I mean measuring currents less than 1 Amp  approximately which are real values for many of the fan motors used.


                                  Well I would love hear about your commentaries about that.


                                  Are you really  from the Vatican State?


                                  Thank you very much  for your time.


                                  Best regards,


                                  Alex101 (You never finish learning)

                                  • 14. Re: Locate array in SRAM

                                    Thank you very much Anks I'll take your suggestion.