Getting 16-bit data through a Filter

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

cross mob
lock attach
Attachments are accessible only for community members.
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Using the PSoC5LP development board CY8CKIT-050, I have found examples of getting 8-bit data out of a filter and into a VDAC. I want to get the digital data out of the Filter into SRAM arrays. In this build, I have verified that I can get data out of the Sequencing SAR but I cannot get data out of the following filter.

   

I initialize two elements of the destination arrays just to see if they get overwritten by new data.  I am using the 10K pot at P6[5] for one data source and from the junction of two 2700 ohm resistors at P3[3] for the other data source.  I use the LCD to write three elements of each array to see what the output looks like.

   

What destination address should I use for the DMAs?  LO16((uint32)Filter_STAGEAM_PTR)
or LO16((uint32)Filter_STAGEAH_PTR)
or LO16((uint32)Filter_STAGEA_PTR)

   

Should I be using Filter_DALIGN_REG |= 0x0F; to align the data?

   

Note that I am not starting the isr_dma here. This was used to successfully read data from the SAR. I start the isr_filt interrupt to get data unsuccessfully from the filter.

   

Can anyone suggest what I am doing wrong or point to an example project that does not involve a VDAC?
 

0 Likes
1 Solution
Anonymous
Not applicable

Looking in your source code, I point some strange code :

   

- DMA setting TD_AUTO_EXEC_NEXT is not correct

   

- not sure relying on Filter_IsInterruptChannelA() for polling while DFB interrupts are not activated is the good way

   

- Your DFB input is a buffer (uint8 DMA_A[LENGTH+4]) with 1 byte elements and you specify burst size 2

   

 

   

Regards,

   

PNN

View solution in original post

0 Likes
18 Replies
lock attach
Attachments are accessible only for community members.
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 Pardon me, but I meant to post this zip file. Please ignore the previous zip and look at this one.

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

Your source is sar_finalArray[] which is not a peripheral, but an array in memory. So using CYDEV_PERIPH_BASE is wrong.

   

Use as destination CYDEV_PERIPH_BASE and Filter_STAGEA_PTR.

   

Is TD_INC_SRC_ADR really correct?

   

 

   

I would suggest you to first work with one channel only and later add the second to see if the two channels influence each other.

   

 

   

Bob

0 Likes
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 Bob, that was a good catch noticing that sar_finalArray[] is in SRAM, not the device. And you're right that I should not have incremented the source. I am in the process of breaking the project down into separately debugged components. I'll post results as I progress. Thank you.

0 Likes
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 I have simlified the project to one step. I am just trying to get 8-bit data through the filter.
The simplified path is:

   

Generate an array with sawtooth data in SRAM.
Feed this SRAM array through DMA to the Filter, then to SRAM array
Then I try to display sample elements of the filter output array on the LCD. Nothing is displayed.  Using polling and checking for interrupt in the while loop.  Debug shows that I never get inside the if statement

   

        if (Filter_IsInterruptChannelA())

   

       {

   

            Filter_A = Filter_Read8( Filter_CHANNEL_A);

   

            n++;

   

        }

   
    Any ideas?   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I am afraid that I cannot judge your issue without a look at all of your settings. Please upload a workspace bundle here to have a look at.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 I am so sorry. I forgot the attachment (duh).

0 Likes
lock attach
Attachments are accessible only for community members.
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 oops again. Here is the zip file workspace bundle.  The clock is set to 1200 Hz.  I'm not sure what frequencies that would produce from the sawtooth wave from my DMA_A initialization. But I would expect some output that would generate an interrupt for the query 
if (Filter_IsInterruptChannelA()) ...

   

Thank you for looking at my query.  -Jerry

0 Likes
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 I still have not solved this problem of how to get 16-bit data (12-bit resolution) through a FIR Filter.  I have tried to do so with DMA, Interrupt, and Polled.

   

I have tried to do it with Filter_DALIGN_REG |= 0x0F; and with Filter_SetCoherency. I have tried to direct the &sar_finalArray[0] to Filter_STAGEAH_PTR, and Filter_STAGEAM_PTR, andFilter_STAGEA_PTR. No combination works.

   

I have read every document I can find on Cypress. Yes, I can find 8-bit examples; but no 16-bit examples.

   

Can anyone provide a working example project in the form of a Workspace Bundle for getting 12 or 16 bit data through a FIR Filter (only need 32KHz low pass)?  Two channels would be great but I would settle for a one-channel working example.

   

Note: I do not want to output to a DAC. I need the output in an SRAM array.

0 Likes
Anonymous
Not applicable

Looking in your source code, I point some strange code :

   

- DMA setting TD_AUTO_EXEC_NEXT is not correct

   

- not sure relying on Filter_IsInterruptChannelA() for polling while DFB interrupts are not activated is the good way

   

- Your DFB input is a buffer (uint8 DMA_A[LENGTH+4]) with 1 byte elements and you specify burst size 2

   

 

   

Regards,

   

PNN

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

TD_AUTOEXEC_NEXT is correct imho. At time of DMA-start all data are present in memory, there is only one DMA_start signal for the complete transfer. and the transfer is done in smaller chunks.

   

 

   

Bob

Anonymous
Not applicable

I misunderstand the documentation (Getting started with DMA).

   

Auto Execute Next TD
0: The next TD in the chain is executed only after the next DMA request.
1: The next TD in the chain is automatically executed after the current TD transfer is finished.

   

I guess the 1200Hz clock is used to process DMA request at the desired rate to feed the Filter at a fixed sampling rate.

   

 

   

Regards,

   

PNN

lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Here is an example project filtering 16 bits values coming from an SRAM array using the "Filter DFB component". A DMA & a clock are used to feed flowlessly the Filter without involving the CPU. Keep us informed if it match your needs.

   

 

   

Regards,

   

PNN

0 Likes
lock attach
Attachments are accessible only for community members.
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 @PNN, Thank you so much for your contribution. I had to upgrade to PSoC Creator 3.1 to read your file -- and that's a good thing.

   

Nevertheless, your contribution was for a 20-bit (24-bit) sample.  Thus, the DALIGN and Coherency parameters are different from a 12 or 16 bit data filter. This is good for anyone searching for such a solution in this Developer Community. Thank you.

   

I opened a log with technical support but the example of 16-bit (or 12-bit) sample takes the LCD printout at the SAR's ISR They comment out the desired result at the Filter.  I have been "playing" with this for days and I cannot get digital results to populate an array out of the filter.  Nada, zilsch, bubkes.

   

Forget the previous zip file.  A better simulation is to use the CYC8KIT-050 Developer Kit  with its onboard potentiometer at P6[5] to simulate "analog" input.  I installed, on the breadboard, a second potentiometer between Vdda and Vdds with the wiper arm at P6[0].

   

Please take a look at this workspace as well as the tech support's suggestion. My file and tech support's file are attached.  I just want digital results out of the Filter to go into an array.  I will process the data later.

   

I cannot get data into the arrays.  I don't care about the VDAC output. This is a Filter problem more than anything.  I can get any data I want out of the SAR.  I cannot get digital data (array) out of the Filter.

   

Please help.

0 Likes
lock attach
Attachments are accessible only for community members.
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 Oops, her is the official reply sample from Technical Support.  So many DMA configs are commented out.  My problem is still not solved. We don't want to sample the SAR. We want digital results (in the form of an array) from the Filter.

   

Jerry

0 Likes
Anonymous
Not applicable

Here is an example project to get 16 bits data from a SAR component (ADC_SAR_Seq) without involving the CPU. This example has been stripped to the minimal configuration for better understanding. If one needs to catch multiple channels, he could increase the numer of analog inputs to the ADC_SAR_Seq, cut&past the same C code and schematic. I check only the behavior with the internal potentiometer (CY8CKIT-050), so impossible to check the filter lowpass "accuracy".

   

IMO, the only way to check the filter accuracy is using a VDAC and a scope to check the output and a signal generator in input with a sine wave at the cut-off frequency and check for -3db.

   

If one wants to fill a bigger buffer than 4095 bytes, he has to initialize and chain multiple TDs (each one is limited to 4095 bytes).

   

 

   

Regards,

   

PNN

lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Here is the project archive.

0 Likes
JeCo_264681
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

 @PNN, Wow!  Your solution exceeds my expectations. It is terrific. From a 12-bit SAR, I find it amazing that I get output approaching 65,535 (216) when 212 would be 4096.  I am still trying to figure out your secret sauce.

   

 

   

There is a line in the dma_restart function that is interesting:

   

CyDmaTdFree(dma_out_A_TD[0]);

   
    Can you explain why this is important? The Cypress documentation is thin here. The DMA Wizard does not provide this.   
   
        
   
    I like the lines:   
   
    
         Filter_SetDalign(Filter_STAGEA_DALIGN, Filter_ENABLED);    
    
         Filter_SetCoherency(Filter_CHANNEL_A, Filter_KEY_MID);    
    
          
    
     to set the Dalign and Coherency.    
    
          
    
     Many thanks. I will contact technical support to suggest that some version of this become an Example Project.    
    
     Aloha.    
    
     Jerry    
   
   
        
0 Likes
Anonymous
Not applicable

The purpose of the dma_restart is to reset the address counter of the TD to avoid a memory corruption on the fixed size buffer. One solution is to destroy the TD and create a new one with the same parameters for reuse during the next transfer. Another way to do is perhaps (not tested) to use the parameter "preserveTDs = false" for the DMA channel.

   

 

   

Regards,

   

PNN

0 Likes