Fix examples isr

This commit is contained in:
nick6x 2017-07-28 16:16:10 -07:00
parent 6f4d8a93c5
commit c4daa7941b
1 changed files with 19 additions and 10 deletions

View File

@ -9,6 +9,8 @@
#define PWM_PIN 3 #define PWM_PIN 3
#define TIMER2_PHASE_ADVANCE 24
DDS dds; DDS dds;
void setup() { void setup() {
@ -26,17 +28,24 @@ void loop() {
dds.setFrequency(2200); dds.setFrequency(2200);
} }
#ifdef DDS_USE_ONLY_TIMER2
ISR(TIMER2_OVF_vect) { //Uncomment if using dds.startPhaseAccumulator(true);
dds.clockTick(); /*ISR(TIMER2_OVF_vect) {
}
#else // Use the ADC timer instead
ISR(ADC_vect) {
static unsigned char tcnt = 0; static unsigned char tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag if(++tcnt == TIMER2_PHASE_ADVANCE) {
if(++tcnt == 4) {
tcnt = 0; tcnt = 0;
dds.clockTick();
}
}*/
//Comment if using dds.startPhaseAccumulator(true);
ISR(ADC_vect) {
if(false){
static unsigned char tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag
if(++tcnt == 4) {
tcnt = 0;
}
dds.clockTick();
} }
dds.clockTick();
} }
#endif