CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

state machine

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mcompile
Guest







state machine
PostPosted: Tue Jan 30, 2007 6:39 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 30, 2007 7:03 am     Reply with quote

Instead of putting them into a buffer, why not just keep a count of them in a variable.
mcompile
Guest







PostPosted: Tue Jan 30, 2007 7:46 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 30, 2007 9:00 am     Reply with quote

I wouldn't scan a keypad in an ISR. Is this a periodic event? If so, then why not process it in the main.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group