Class D adcDelSig>Filter>Pwm using DMA only

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.
Anonymous
Not applicable

Hi, this is my first project and am having a bit of a struggle getting this to work. Basically the adc is differential with an audio input sampled at 192Ksps>Filter for Low Pass.

The problem occurs trying to get the Filter value out of the DMA to the Pwm compare1 register.

I am attaching the project bundle.

Any help or pointers would be very much appreciated.

Thanks in Advance

Al

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

I modified T. Dust demo to include 2s-compliment to binary offset conversion using Control register.  Project uses hardware input PWM (using custom component made by JLS1), but can be further modified to use DMA transfer. I think this is enough to start with.

ADC-Filter-VDAC_01s_01.png

ADC-Filter-VDAC_01s_PWM_01.png

PWM_Cap 0.1uF.jpg

PWM ouptut w/o and with external 0.1uF bypass capacitor (too big?).

P.S. Project updated (PWM pin is relocated and set to resistive pull up/down).

View solution in original post

10 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

The Filter output is a signed value, but PWM can take positive only, that is the problem. You need to add offset to change output from 2's compliment to binary offset (+128 for 8-bit). Easyest way is to do it without DMA, but use isr on filter output ready and do it In code.

To accomplish same using DMA try using intermediate buffer constructed of control and status registers, using the idea brought by the 'pavloven', see attached image. So in your case it will look like Filter->DMA->ControlReg->StatusReg->PWM.

2 ADC >> 2 DMA >> Filter >> 2 DAC

DAC (1).JPG

Anonymous
Not applicable

Thanks for taking the time to reply, much appreciated. Unfortunately im a bit of a noob to programming so its going to take me a while to figure it out, i understand the principle but actual execution will take me some time.......best start reading those pdf's then .

Thanks again

Al

0 Likes

I always had in mind to build a simple component capable of DMA transfer that does the conversion. Just using a couple of UDBs depending on the item width. Sorry, no time... Someone else???

Bob

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

The project you attached does not open correctly, try to re-submit it. Judging from the schematic page you have used ADC-Filter-DAC example by Todd Dust:

PSoC 5LP Digital Filter - Hackster.io

How to Create an Analog Filter with PSoC 5LP - YouTube

which allegedly shows Filter-DMA-VDAC transfer with the sign correction. I was not able to reproduce that project, and all I see is 2's-compliment output.

I suspect that T. Dust has used modified Filter component in his demo. I suggest contacting him for explanation.

P.S. I opened a support case re Filter demo, Lets see what comes out.

lock attach
Attachments are accessible only for community members.

I modified T. Dust demo to include 2s-compliment to binary offset conversion using Control register.  Project uses hardware input PWM (using custom component made by JLS1), but can be further modified to use DMA transfer. I think this is enough to start with.

ADC-Filter-VDAC_01s_01.png

ADC-Filter-VDAC_01s_PWM_01.png

PWM_Cap 0.1uF.jpg

PWM ouptut w/o and with external 0.1uF bypass capacitor (too big?).

P.S. Project updated (PWM pin is relocated and set to resistive pull up/down).

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

Thank you so much again for your time in responding, sorry it took me so long to come back on this, but i got it working(after much reading of various pdf's and examining sample codes)

All done with DMA and the conversion of integers seems to work fine, thank you again.

Final project attached.

0 Likes

Sorry,

the attached project is corrupted and doesn't load into Creator 4.0/ 4.1. Can you please re-upload the project?

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

try this....

0 Likes