PSoC™ 5, 3 & 1

Anonymous
Not applicable

How do I change the phase of a sine wave generated by a DMA?

I am practicing setting up DMAs by using the examples given here:

http://www.cypress.com/documentation/application-notes/an52705-psoc-3-and-psoc-5lp-getting-started-d...

I would like to be able to change the phase of the sine wave by using a potentiometer. Does anyone have any tips on how to accomplish this?

1 Solution
Level 9
Level 9

Re: How do I change the phase of a sine wave generated by a DMA?

choblet,

I looked through few options, it seems the most stable for multiple sine outputs is the project created by Evgeniy Pavlov (AKA 'pavloven') on Jun 18, 2016:

Generating multiple waveforms with fixed phase relationships

To keep two sine outputs synchronized it uses intermediate location in memory, which data is fetched by 32-bit DMA source. To have sine phase shifted, the sourcing array in RAM is simply re-calculated, which takes some time and may (potentially) lead to discontinuities when old data in RAM is being overridden.

I cosmetically freshened the original project, translating comments to English and adding phase update on timer event. Project is attached

/odissey1

5 Replies
Level 9
Level 9

Re: How do I change the phase of a sine wave generated by a DMA?

choblet,

The sine wave has no phase by itself, only as referenced to another wave of the same frequency. That second wave can be e.g. TTL-level digital signal with 50% duty cycle, or yet another sine/cosine wave (and the implementation would vary). So what exactly you looking for?

/odissey1

Anonymous
Not applicable

Re: How do I change the phase of a sine wave generated by a DMA?

I'm actually generating two sine waves using the same lookup table, and one of them will remain unshifted for reference.

I use a DMA to transfer the data from the array into SRAM so I can reach higher frequencies.

From there I am able to set up two DMA channels with separate TDs that take data from the table and send it to their respective VDACs. I output the signals to pins and observe two sine waves on the scope.

I found that I can change the frequency of the signal by changing the frequency of the clock to one of the DMAs, but I haven't found a way to change the phase yet.

I would essentially like to be able to control the phase shift of one wave relative to the other by using a potentiometer.

I don't even know or understand how the DMAs or TDs work well enough to figure out what I would change to get the wave to shift. I've been reading the documentation and tinkering around, but I haven't been able to observe any results, so I don't know what affects what.

I have tried changing the address in the lookup table that the TD goes to, hoping that if the address pointed to data entry 64 of the 128 data points it would shift the signal by 90 degrees, but I couldn't figure it out.

Level 9
Level 9

Re: How do I change the phase of a sine wave generated by a DMA?

There are several solutions available, I will draft some demo on weekend.

Anonymous
Not applicable

Re: How do I change the phase of a sine wave generated by a DMA?

Thank you, I would greatly appreciate it.

Level 9
Level 9