hello everyone
I just would like to generate a sine wave with a (100 Hz - 10MHz) range of frequency
I try to use the following code and I try to change the waiting time but it cannot be less than 1 so the highest value of freq. does not reach even 1KHz
how can I generate a sine wave with a high range of freq?
I don't know a a lot about teensy programming, so I cannot change the code deeply to be fit with my requirements.
the code is:
///////////////////////////////////////////////////////////////////////////////////////
// Simple DAC sine wave test on Teensy 3.1
float phase = 0.0;
float twopi = 3.14159 * 2;
elapsedMicros usec = 0;
void setup() {
analogWriteResolution(12);
}
void loop() {
float val = sin(phase) * 2000.0 + 2050.0;
analogWrite(A14, (int)val);
phase = phase + 0.02;
if (phase >= twopi) phase = 0;
while (usec < 500) ; // wait
usec = usec - 500;
}
///////////////////////////////////////////////////////
or you can find it here : https://www.pjrc.com/teensy/teensy31.html
thanks in advance
I just would like to generate a sine wave with a (100 Hz - 10MHz) range of frequency
I try to use the following code and I try to change the waiting time but it cannot be less than 1 so the highest value of freq. does not reach even 1KHz
how can I generate a sine wave with a high range of freq?
I don't know a a lot about teensy programming, so I cannot change the code deeply to be fit with my requirements.
the code is:
///////////////////////////////////////////////////////////////////////////////////////
// Simple DAC sine wave test on Teensy 3.1
float phase = 0.0;
float twopi = 3.14159 * 2;
elapsedMicros usec = 0;
void setup() {
analogWriteResolution(12);
}
void loop() {
float val = sin(phase) * 2000.0 + 2050.0;
analogWrite(A14, (int)val);
phase = phase + 0.02;
if (phase >= twopi) phase = 0;
while (usec < 500) ; // wait
usec = usec - 500;
}
///////////////////////////////////////////////////////
or you can find it here : https://www.pjrc.com/teensy/teensy31.html
thanks in advance