PDA

View Full Version : timer and serial interrupt



yourmomOS
- 14th July 2006, 03:39
Hi all, I have a working program that uses serial interrupts for communications. I need to add a timer that will count to say...30 seconds. I can check for it in my main loop and do something when it reaches 30. Or maybe use the timer interrupt. The only problem is I dont want to jump to my serial code for the timer interrupt. Any ideas?

mister_e
- 14th July 2006, 03:47
you can still read the TIMER register and react... but a timer interrupt is really good so i don't know why you don't want to use it.

Test drive the Darrel Taylor instant interrupts...

yourmomOS
- 14th July 2006, 16:59
I dont want anything to get in the way of receiving the serail data. If I interrupt to a timer, I may miss a character comming into the serial buffer. I have determined the serial data is more important then the data that will be recorded when the 30 second interval(or whenever) happens.
Also, I dont know assembly.

If I were to enable the timer1 and set it up to overflow every 30 seconds, (if possible), In order for it to not jump to the interrupt, I would set the PIE bit to 0 but check for the PIR bit to be 1? correct?

paul borgmeier
- 14th July 2006, 18:02
...I can check for it in my main loop and do something when it reaches 30. ... Any ideas?
Although Interrupts sound like the ideal way ... another approach:

I posted some short code examples in the code examples section that might be used for your 30 second timer. They are based on polling TMRO overflows and not interrupts. Have a look at the second program and see if it might work for you.

http://www.picbasic.co.uk/forum/showthread.php?t=2129

Good Luck,
Paul Borgmeier
Salt Lake City, Utah
USA