My goal is to output a PWM signal from my ATtiny84 with 1ms high at 50hz. The clock is operating at 1mhz, so I've set the compare output mode such that the output pin should be cleared for 19000 clock ticks and be set for 1000.
The device is powered at 5V and I have an oscilloscope reading a flat 5V output from pin A5 (OC1B), no modulation. My code is here:
#include <avr\io.h>
void init_pwm_generator()
{
PORTA &= ~(1 << (PORTA5));
ICR1 = 20000;
TCCR1A = (1<<COM1B1) | (1<COM1B0) | (1<<WGM11);
TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS10);
}
int main(void)
{
DDRA |= (1 << (DDA5));
init_pwm_generator();
while(1)
{
OCR1B = ICR1 - 1000;
}
}
I can't figure out why this isn't working!