Added a define to use pin 3 for PWM, instead of the new default pin 11.
This commit is contained in:
parent
8f2115adbc
commit
016ad2398a
6
DDS.cpp
6
DDS.cpp
|
@ -10,8 +10,14 @@ void DDS::start() {
|
|||
// First, the timer for the PWM output
|
||||
// Setup the timer to use OC2B (pin 3) in fast PWM mode with a configurable top
|
||||
// Run it without the prescaler
|
||||
#ifdef DDS_PWM_PIN_3
|
||||
TCCR2A = (TCCR2A | _BV(COM2B1)) & ~(_BV(COM2B0) | _BV(COM2A1) | _BV(COM2A0)) |
|
||||
_BV(WGM21) | _BV(WGM20);
|
||||
#else
|
||||
// Alternatively, use pin 11
|
||||
TCCR2A = (TCCR2A | _BV(COM2A1)) & ~(_BV(COM2A0) | _BV(COM2B1) | _BV(COM2B0)) |
|
||||
_BV(WGM21) | _BV(WGM20);
|
||||
#endif
|
||||
TCCR2B = (TCCR2B & ~(_BV(CS22) | _BV(CS21))) | _BV(CS20) | _BV(WGM22);
|
||||
|
||||
// Set the top limit, which will be our duty cycle accuracy.
|
||||
|
|
5
DDS.h
5
DDS.h
|
@ -3,6 +3,11 @@
|
|||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
// Use pin 3 for PWM? If not defined, use pin 11
|
||||
// #define DDS_PWM_PIN_3
|
||||
|
||||
// Use a short (16 bit) accumulator. Phase accuracy is reduced, but speed
|
||||
// is increased, along with a reduction in memory use.
|
||||
#define SHORT_ACCUMULATOR
|
||||
|
||||
#ifdef SHORT_ACCUMULATOR
|
||||
|
|
Loading…
Reference in New Issue