Hello.
I need to start a 5 minutes countdown on a pic16f690.
I have the very simple main program:
Loop
@ sleep
Goto loop
Then I have an int handler for triggerings on porta pins. In fact there are ir receivers on each porta pin and an ir beam triggers an int and specific actions are taken.
I would need to use timer0 overflow interrupt. What I read from the datasheet is that timer0 is a 8 bits timer that can be used as either a counter or a timer, with prescaler.
If I am using:
Define Osc 8
I assume it means clock speed is 8000000 clock cycles per 1000000 microseconds, thus 125ns clock cycles.
Right?
If tmr0 is updated at every clock cycle it takes 256*125ns to set the tmr0 overflow flag in intcon register. If I use a 1:256 prescaler, it will take 256*256*125ns (=8.192 ms) before tmr0 overflows.
Is that correct?
I would need 36621 iterations of a counter variable to get 5 minutes countdown (300000/8.192).
Right?
If I add in my int handler a routine that will increment a word variable at every tmr0 overflow, I can still get porta change interrupts.
Right?
I could have used a loop but during the loop (inside the int handler) no interrupt would occur.
What do you think?
Thanks a lot.
Bookmarks