Added DDS sample. Fixed pin 11 PWM output, now default (3 works better).
This commit is contained in:
32
examples/DDS/DDS.ino
Normal file
32
examples/DDS/DDS.ino
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <HamShield.h>
|
||||
#include <Wire.h>
|
||||
|
||||
DDS dds;
|
||||
|
||||
void setup() {
|
||||
pinMode(2, OUTPUT);
|
||||
pinMode(3, OUTPUT);
|
||||
pinMode(11, OUTPUT);
|
||||
dds.start();
|
||||
dds.setFrequency(440);
|
||||
dds.on();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
dds.setFrequency(2200);
|
||||
delay(5000);
|
||||
dds.setFrequency(1200);
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
#ifdef DDS_USE_ONLY_TIMER2
|
||||
ISR(TIMER2_OVF_vect) {
|
||||
dds.clockTick();
|
||||
}
|
||||
#else // Use the ADC timer instead
|
||||
ISR(ADC_vect) {
|
||||
TIFR1 = _BV(ICF1); // Clear the timer flag
|
||||
dds.clockTick();
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user