I am trying to get a digital sound output from the Arduino Due using this tutorial:
This tutorial was made using the Nano board. The timer interrupts are different on the Due and I cannot seem to find any straight-forward way to change them to be compatible with the Due's ATSAM3X8E chip.
The nano uses:
/****Set timer1 for 8-bit fast PWM output ****/
pinMode(9, OUTPUT); // Make timer’s PWM pin an output
TCCR1B = (1 << CS10); // Set prescaler to full 16MHz
TCCR1A |= (1 << COM1A1); // Pin low when TCNT1=OCR1A
TCCR1A |= (1 << WGM10); // Use 8-bit fast PWM mode
TCCR1B |= (1 << WGM12);
/******** Set up timer2 to call ISR ********/
TCCR2A = 0; // No options in control register A
TCCR2B = (1 << CS21); // Set prescaler to divide by 8
TIMSK2 = (1 << OCIE2A); // Call ISR when TCNT2 = OCRA2
OCR2A = 32; // Set frequency of generated wave
sei(); // Enable interrupts to generate waveform!
}
While the Due no longer uses TCCR__
I found some resources on how the new Due uses the 32 bit clock, but not how to call upon said clock, let alone call upon and 8 bit mode. If anyone has any resources or sample codes it would be much appreciated.