When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals.
How can I do what I want using the read_counter() function?
The problem here is that I am already in the timer function with the read_counter() function.
void wait_function() {
timer_init();
while(read_counter()<30000) { //30 second wait
// A LED blinking at 1 second intervals ???
}
}
Note: The read_counter() function increases every 1 millisecond with ISR COMPA vector. I tried many times and couldn't find a stable solution. Example:
if (read_counter() % 1000) PORTB^=(1<<LED);
Update: My new code :
while((TIFR1 & (1 << OCF1A))==0) //4secondIf I do this cycle 8 times, it
//makes 32 seconds.
{
if(TCNT1%15624==0) //per 15624=1 second,
PORTA^=(1<<0);
//led_blink_1s
}
But,it doesn't work.Should I use util delay function?