volatile unsigned int Acc, Jump;
unsigned int Freq = 100 ;
void SetupDDS () {
// Enable 64 MHz PLL and use as source for Timer1
PLLCSR = 1<<PCKE | 1<<PLLE;
// Set up Timer/Counter1 for PWM output
TIMSK = 0; // Timer interrupts OFF
TCCR1 = 1<<PWM1A | 2<<COM1A0 | 1<<CS10; // PWM A, clear on match, 1:1 prescale
pinMode(1, OUTPUT); // Enable PWM output pin
// Set up Timer/Counter0 for 20kHz interrupt to output samples.
TCCR0A = 3<<WGM00; // Fast PWM
TCCR0B = 1<<WGM02 | 2<<CS00; // 1/8 prescale
TIMSK = 1<<OCIE0A; // Enable compare match, disable overflow
OCR0A = 60; // Divide by 61
}
ISR(TIMER0_COMPA_vect) {
//Square ()
Acc = Acc + Jump;
int8_t temp = Acc>>8;
OCR1A = temp>>7;
// void Sawtooth () {
// Acc = Acc + Jump;
// OCR1A = Acc >> 8;
// }
}
void setup() {
SetupDDS ();
Jump = Freq*4;
GIMSK = 1<<PCIE; // Enable interrupt
GIFR = 1<<PCIF;
}
void loop() {
// put your main code here, to run repeatedly:
}