Looking for example code of using the streamer to generate a sine wave output on the dac (solved)
Bean
Posts: 8,129
Specifically I'm trying to generate a 9.999MHz sine wave with a system clock of 250MHz, but I'll take anything I can get.
I'm confused because is the DAC in the streamer or in the smart pin ? I see references to both.
Thanks,
Bean
I'm confused because is the DAC in the streamer or in the smart pin ? I see references to both.
Thanks,
Bean
Comments
If you look at Chip's Goertzel demos he is streaming a few different sine waves from lut tables to the DACs, where the channels streamed have 90 (4ch) or 120 (3ch) phase shifts between them
Does anyone have a link to this demo ?
Thanks,
Bean
https://forums.parallax.com/discussion/170783/goertzel-board-demo-for-p2-rev-b
I think that the demo code was also included in v33 pnut release
Bean
There's also a .wav file player around that can show you some tips.
But, for just a sin wave, I guess I'd use the cordic qrotate function to generate samples...
I assume it can do that without the COG being involved ? Once it is setup of course.
From what I read, I assume you have to use Goertzel mode, but I don't know that for sure.
Any help would be appreciated,
Bean
P.S. I'm using PASM2, but SPIN2 code will probably help too.
https://forums.parallax.com/discussion/170820/hdmi-4-channel-oscilloscope-demo/p2
Just pull out the DDS part and tweak for your needs.
He generates the wave data in the LUT and then uses the stream to output it...
Somehow, he can vary the waveform frequency too.
I used to know how that worked, but forgot...
I'll look at it tomorrow when I'm back at work.
I don't have a scope here at home.
Bean
Here it what I have:
If anyone can tell me what the values that I have ??? as comments for, I will add that info.
Bean
That seems like a lot of precision...
The DOCs say you should get
250M/0x80000000*(round(0x80000000*9.999M/250M)) = 9999000.00169 Hz
and the next step is 9999000.118114 Hz
with a step size of 116.415mHz
There will be some jitter on that from the DDS adder quantize, plus some PLL jitter, but those averages will be the result.
Just so everyone knows, I spent a couple hours because there was a glitch on the sine wave and I couldn't figure out a way to get rid of it.
Then, while removing code from Chip's demo I removed the code that generated the triange, sawtooth and squarewave on the other pins and it magically went away. Doh....
Bean
That sort of coupling was fixed in rev.B silicon ...
But somehow I’m thinking it showed up in chips demo mentioned above...
Just to be clear it was fixed in rev C silicon, not rev B silicon. (It was observed as an artifact in Rev B, causing the cut to me made, that fixed it in Rev C)
I was using an 12" 3-pin header wire so I had Gnd-Sin-Sawtooth right next to each other.
At the falling edge of the sawtooth, I would get a negative glitch on the sine wave.
I am using the Rev C eval board.
Bean