Why is my ATmega32 timer interrupt not executing?

hello I am beginning interfacing on the atmega32 and I am getting started with the peripherals and now I am stuck with the timers, this code isnt executing the interrupt code for some reason #include<avr/io.h> #include<util/delay.h> #include<avr/interrupt.h> int main(void){ SREG=1<<7;//enable the I-bit DDRC=0x01;//output PORTC=0x00;//initializing not depending on default values in the datasheet TCCR0=0x05;//setting the value of the prescaler TIMSK=0x03;//enabling the interrupt of overflow and compare for(;;){ } } ISR(TIMER0_OVF_vect){ PORTC^=0x01; }
33 Replies
Shousha
Shousha•2mo ago
help would be appreciated
Mr_UJ 🔋
Mr_UJ 🔋•2mo ago
on overflow ISR you have to set timer value, that to be overflowed next time
Shousha
Shousha•2mo ago
that is the only thing missing?
Shousha
Shousha•2mo ago
I think I did that but it didnt do nth w8 I will try
Mr_UJ 🔋
Mr_UJ 🔋•2mo ago
Yes, is the register settings are correct
Mr_UJ 🔋
Mr_UJ 🔋•2mo ago
in this you haven't set TCNT0 register
Mr_UJ 🔋
Mr_UJ 🔋•2mo ago
In which mode you want to use timer?? * Overflow ? * Compare ? etc?
Shousha
Shousha•2mo ago
still doesnt work
Shousha
Shousha•2mo ago
I only added the TCNT0 initial value to zero
Shousha
Shousha•2mo ago
and it still doesnt work
Shousha
Shousha•2mo ago
I am trying the overflow mode rn
Shousha
Shousha•2mo ago
I set the internal clock to 1 MHz
Shousha
Shousha•2mo ago
and reduced the prescaler value
Shousha
Shousha•2mo ago
and it still doesnt work
Mr_UJ 🔋
Mr_UJ 🔋•2mo ago
check timer register settings, is the settings correct for overflow enable?
Want results from more Discord servers?
Add your server