Hi, thanks for the quick response. I was using the PWM library by Sam Knight. I use the PWM outputs to drive Vactrols to simulate potentiometers.
Original repository
https://code.google.com/archive/p/arduino-pwm-frequency-library/downloads
Original Arduino Forum library post by Runnerup (Sam Knight):
https://forum.arduino.cc/index.php?topic=117425.0
and my code is below. The compilation errors are due to the fact that the library has not been updated to support the Giga board, so the variable names for the registers (TCCR1B etc.) are not included in the build (undefined value errors). I could hack the library and add a definition so that they were defined again, but are the timer registers compatible between Mega and Giga boards? (i.e are they are the same addresses and is it the same chip?)
Is there another way to change PWM frequency?
void pwmSetup() {
// PWM pins
pinMode(VOLUME1_PIN_A, OUTPUT);
pinMode(VOLUME1_PIN_B, OUTPUT);
pinMode(TONE1_PIN, OUTPUT);
pinMode(VOLUME2_PIN_A, OUTPUT);
pinMode(VOLUME2_PIN_B, OUTPUT);
pinMode(TONE2_PIN, OUTPUT);
pinMode(VOLUME3_PIN_A, OUTPUT);
pinMode(VOLUME3_PIN_B, OUTPUT);
pinMode(TONE3_PIN, OUTPUT);
// Leave timer 0 alone, don't use pins 4, 13
//change frequency for Timer 1: Pins 11,12
int myEraser = 7; // this is 111 in binary and is used as an eraser
int myPrescaler = 1; // this could be a number in [1 , 6]. In this case, 1 corresponds in binary to 001.
TCCR1B &= ~myEraser; // this operation (AND plus NOT), set the three bits in TCCR1B to 0
TCCR1B |= myPrescaler; //this operation (OR), replaces the last three bits in TCCR1B with our new value 001, 31kHz
TCCR2B &= ~myEraser; // this operation (AND plus NOT), set the three bits in TCCR2B to 0
TCCR2B |= myPrescaler; //this operation (OR), replaces the last three bits in TCCR2B with our new value 001, 31kHz
TCCR3B &= ~myEraser; // this operation (AND plus NOT), set the three bits in TCCR2B to 0
TCCR3B |= myPrescaler; //this operation (OR), replaces the last three bits in TCCR2B with our new value 001, 31kHz
TCCR4B &= ~myEraser; // this operation (AND plus NOT), set the three bits in TCCR2B to 0
TCCR4B |= myPrescaler; //this operation (OR), replaces the last three bits in TCCR2B with our new value 001, 31kHz
// set initial volume
pwmVolume();
}