- This topic has 1 reply, 2 voices, and was last updated 12 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › PIC › How to count milliseconds with PIC18F4550?
Hi,
I need a way to calculate the time in milliseconds. I’ve been tried to work with the PIC’s Timers but I don’t understood.
But I also need a way to stop and restart the countage: stop when an event occurs and restart when that event stop.
I heard that the interrupts plays a role in cases like this, but I don’t know how to use them.
Please, any suggestion is very helpful.
Thanks for your time (literally).
Hi Alison,
Try these algorithm for your “stop when an event occurs and restart when that event stop”
1) Configure external interrupt as positive edge triggered
2) Enable external interrupt
3) When interrupt occurs do the step 4) to 7)
4) In interrupt ISR, disable the external interrupt
5) Reconfigure the external interrupt as negative edge triggerd
6) Enable external interrupt again
7) If the count is stopped already, then restart count, otherwise stop the count
There is a lot to learn about interrupts, ISR and how to implemnt them in your microcontroller.