I've been working on a project and it requires that I have a 60khz sine wave, I'd like to be able to adjust it a little in software, in 1khz increments would be OK, but if I can go finer than that, all the better.. however...
I made a sketch that uses the built in cosine generator and I can only get about 32.5 khz out of it according to my scope, and the waveform, while not perfect is certainly sufficient for my needs... The ESP32 literature says it can do up to 100khz.. Where am I going wrong? Is it perhaps something in the library?
32.5 khz sound suspiciously close to 2^15 so I'm wondering if there's a data conversion problem
To assure at least 256 points per cycle the value for SW_FSTEP_MAX should not exceed 256 which still results in a possible highest output frequency of ~32kHz.
** SW_FSTEP_MAX = 64 --> voltage steps per cycle >= 1024, fmax ~7.8kHz*
** SW_FSTEP_MAX = 128 --> voltage steps per cycle >= 512, fmax ~15.6kHz*
** SW_FSTEP_MAX = 256 --> voltage steps per cycle >= 256, fmax ~31.3kHz*
** SW_FSTEP_MAX = 512 --> voltage steps per cycle >= 128, fmax ~62.6kHz*
so if you want to go above ~32KHz you'll have to sacrifice the number of steps (128 instead of 256) for a period
If op adds a small RC filter, a 128 step cosine will be pretty smooth...
Even a square wave can be changed to something that looks like a cosine with 3 rc filters in series...
I think that's what's happening,.. now I'm really not sure how to access the register to change that, I'm assuming there's an added line needed in the setup?
I found it, and it's working now
I changed the Step size in the CPP file to 1024 and turned off High accuracy
Really sucks you have to go into the header and cpp files to make those changes
The calculated clock speed isn't quite right,
This fixed it // Master clock for digital controller section of both DAC & ADC systems. // According to spec approximately 8MHz. #define CK8M 8430400UL
5% off on clock speed is pretty bad, hopefully it doesn't change too much over time and temperature