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?
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.
There are several solutions available, I will draft some demo on weekend.
Thank you, I would greatly appreciate it.
1 of 1 people found this helpful
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:
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