Fix examples isr
This commit is contained in:
		
							parent
							
								
									6f4d8a93c5
								
							
						
					
					
						commit
						c4daa7941b
					
				| 
						 | 
					@ -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
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue