hi guys I am new to AVR world I wanted to know what is the wrong with my code there are no errors in my code but in proteus simulator its still working on 100% speed or full duty cycle any advice?
#include <avr/io.h> #include <avr/interrupt.h> void Timer0_PWM(unsigned char duty_cycle){ TCNT0=0; OCR0=duty_cycle; DDRD |= (1<<3); TCCR0 = (1<<WGM00) | (1<<WGM01) | (1<<COM01) | (1<<CS01); } int main (void) { Timer0_PWM(64); DDRA &= ~(1<<0); DDRA &= ~(1<<1); DDRA &= ~(1<<2); DDRC |= (1<<0); DDRC |= (1<<1); PORTC &= ~(1<<0); PORTC &= ~(1<<1); while (1) { if (PINA & (1<<0)) { PORTC |= (1<<0); PORTC &= ~(1<<1); } else if (PINA & (1<<1)) { PORTC &= ~(1<<0); PORTC |= (1<<1); } else if (PINA & (1<<2)) { PORTC &= ~(1<<0); PORTC &= ~(1<<1); } } }