Jack,
Thank you for your continuing support on the 1284p! I'll try to do this myself but I'm not too familiar with the timers:
Which PWM pin gets broken if you use the tone() function. Official arduino has it in the reference:
http://arduino.cc/en/Reference/Tone
I guess this is the revelent code in Tone.cpp
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
#elif defined(__AVR_ATmega8__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
#elif defined(__AVR_ATmega32U4__)
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER3
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 3 /*, 1 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
#else
#define AVAILABLE_TONE_PINS 1
#define USE_TIMER2
// Leave timer 0 to last.
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
#endif
So 1284p is the #else case that uses timer2, which breaks pwm of pins ???
According to 324/644/1284 spec sheet:
Peripheral Features
̶ Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
̶ One/two 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and
Capture Mode
So this is from bobuino pins_arduino.h
const uint8_t PROGMEM digital_pin_to_timer_PGM[NUM_DIGITAL_PINS] =
{
NOT_ON_TIMER, // D0 PD0
NOT_ON_TIMER, // D1 PD1
NOT_ON_TIMER, // D2 PD2
NOT_ON_TIMER, // D3 PD3
NOT_ON_TIMER, // D4 PB0
NOT_ON_TIMER, // D5 PB1
NOT_ON_TIMER, // D6 PB2
TIMER0A, // D7 PB3
TIMER1A, // D8 PD5
TIMER2B, // D9 PD6
TIMER0B, // D10 PB4
NOT_ON_TIMER, // D11 PB5
TIMER3A, // D12 PB6
TIMER3B, // D13 PB7
NOT_ON_TIMER, // D14 PA0
NOT_ON_TIMER, // D15 PA1
NOT_ON_TIMER, // D16 PA2
NOT_ON_TIMER, // D17 PA3
NOT_ON_TIMER, // D18 PA4
NOT_ON_TIMER, // D19 PA5
NOT_ON_TIMER, // D20 PA6
NOT_ON_TIMER, // D21 PA7
NOT_ON_TIMER, // D22 PC0
NOT_ON_TIMER, // D23 PC1
NOT_ON_TIMER, // D24 PC2
NOT_ON_TIMER, // D25 PC3
NOT_ON_TIMER, // D26 PC4
NOT_ON_TIMER, // D27 PC5
NOT_ON_TIMER, // D28 PC6
NOT_ON_TIMER, // D29 PC7
TIMER1B, // D30 PD4
TIMER2A, // D31 PD7
};
So can I say that D9 and D31 PWM are broken if Tone is used, since they use timer2? Thanks.