Hi all, I have a project where I am using timers 1 and 2 of an ATTiny841. I am wanting to configure all of them to be 10-bit, fast PWM with no prescaler. I am using Dr. Azzy's ATTiny Core, running the chip at 8 MHz. I have read out the fuses to verify. I have also spent a ton of time in the data sheet trying to figure out what is going on. My code is posted below, but first, the issues I see. TOCC3 and TOCC4 are showing the same pulse train of 28.5 us on, 95 us off, roughly a 20% duty cycle. TOCC2 shows a pulse train of 79 ms on, 79 ms off. TOCC1 shows a static +5V (100% duty cycle). This really has me scratching my head, but it must be something stupid that I just must have glossed over in the data sheet or something. Any help would be greatly appreciated. Also, I have been trying some different ways of representing the data, so you will see binary, bit-shifting, etc. in the code. I know it's inconsistent, but the compiler doesn't mind right now. I'll fix it when I get this actually working. Thanks in advance!
//Set up the timer outputs to the correct pins. Don't touch timer 0 so that millis() works correctly
//Pin 8 -> PWM2 -> TOCC4 (make timer OC2B)
//Pin 9 -> PWM1 -> TOCC3 (make timer OC2A)
//Pin 10 -> PWM3 -> TOCC2 (make timer OC1B)
//Pin 11 -> PWM4 -> TOCC1 (make timer OC1A)
TOCPMSA0 = (1<<TOCC1S0) | (1<<TOCC2S0) | (1<<TOCC3S1); //This sets TOCC1 throught TOCC3
TOCPMSA1 = (1<<TOCC4S1); //This sets TOCC4 to be OC2B
TOCPMCOE = (1<<TOCC1OE) | (1<<TOCC2OE) | (1<<TOCC3OE) | (1<<TOCC4OE); //Enable the time/output compare on TOCC1-4
//Disable interrupts on timers
TIMSK1 = 0;
TIMSK2 = 0;
//Set up 16 bit timers so that we can use PWM
//PWM is 10-bit fast, 0x03FF TOP, no prescaler
//Set to Fast, 10-bit PWM, max value of 1024
TCCR1A = 0b10100011; //TCCR1A = _BV(COM1A1) | _BV(WGM10) | _BV(WGM11);
TCCR1B = 0b00001001; //No prescaler, | _BV(WGM12)
TCCR1C = 0b00000000; //Set to zero when in PWM mode
TCCR2A = 0b10100011; //TCCR2A = _BV(COM2A1) | _BV(WGM20) | _BV(WGM21); //Set to Fast, 10-bit PWM, max value of 1024
TCCR2B = 0b00001001; //No prescaler, | _BV(WGM22)
TCCR2C = 0b00000000; //Set to zero when in PWM mode
ICR1 = 20000 - 1;
ICR2 = 20000 - 1;
//Set up an ISR for the encoder switch pin so that it reacts instantly
//and to reduce loop execution time with determining multiplier
GIMSK = 0b00110000; //enable pin change interrupts for all pins
PCMSK0 = 0b00000011; //enable PCINT0/Pin13 and PCINT1/Pin12 as pin change interruptible for encoder pins
PCMSK1 = 0b00000011;