#include <mega8535.h>
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
delay = delay + 1
}
void main(void)
{
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 3.906 kHz
// Mode: Normal top=FFh
TCCR0=0x05;
TCNT0=0xD9;
// Timer0 enable
TIMSK=0x01;
// Global enable interrupts
#asm("sei")
while (1)
{
delay(100); //(100*10ms=1000ms)
};
}
void delay(int delay_ms)
{
TCNT0=0xD9; //timer interval= 10 ms
delay=0
while(delay<=delay_ms)
{
}
}