Locate array in SRAM

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

cross mob
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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.

0 Likes
14 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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;

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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.

   

Alex

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

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

   

http://www.cypress.com/documentation/code-examples/ce95316-filter-adc-vdac-using-dfb-psoc-35lp

0 Likes

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

   

Regards,

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

 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

   

CY_ISR(OneSecond_ISR)
{
 
      Timer_1_STATUS_TC;

   

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

   

 

   

Bob

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Hi Bob

   

Thank you very much, I will try your approach.

   

Alex

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Alex101,

   

for DelSig_ADC-DMA-DFB example see this link:

   

https://www.hackster.io/bmah/psoc-5lp-16-bit-and-24-bit-digital-filter-code-examples-ddcf9c

   

 

   

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

   

https://www.youtube.com/watch?v=oq8eQhvkceM&index=4&t=4s&list=PLTOgiG3Fis5pGCozCjvKxMEx5s0Qiw9Wn

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Hi oddisey1

   

Thank you very much.

   

Very kind of you.

   

Alex 101

0 Likes
lock attach
Attachments are accessible only for community members.
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Alex101,

   

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)

   

 

   

  

   

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

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)

0 Likes