View previous topic :: View next topic |
Author |
Message |
mcompile Guest
|
state machine |
Posted: Tue Jan 30, 2007 6:39 am |
|
|
hey
iam trying to implement a state machine on a PIC16F876
Iam using timer0 to setup timed events a tick for every 13.1ms,
a tick100 for 100ms and a ticksec for 1sec. I place these in a buffer when they occur inside the interrupt service routine.
The problem is that the tick happens alot quicker obvioulsy so the buffer gets filled with tick events, then the odd tick100 and ticksec.
In normal program flow the program graps all these tick events and runs them within a few ms from the buffer. I know fundamentally my buffer idea is the problem, iam windering if anyone has done something similar or would have any advice on setting up such a scheme??
Thanks
Michael |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Jan 30, 2007 7:03 am |
|
|
Instead of putting them into a buffer, why not just keep a count of them in a variable. |
|
|
mcompile Guest
|
|
Posted: Tue Jan 30, 2007 7:46 am |
|
|
Thanks for the suggestion!
I started using a buffer because i want to put other events in the
queue, for example the keypad is scanned during the ISR aswell and this may or maynot place an event in the queue.
I was thinking of checking the buffer for example a tick event and if there is one there then dont place another one in the buffer. How does this sound? My main concern is that i dont want to spend two long in the ISR?
Thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Jan 30, 2007 9:00 am |
|
|
I wouldn't scan a keypad in an ISR. Is this a periodic event? If so, then why not process it in the main. |
|
|
|