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 CCS Technical Support

how do you make a state machine using a PIC?

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



Joined: 12 May 2005
Posts: 15

View user's profile Send private message

how do you make a state machine using a PIC?
PostPosted: Fri May 13, 2005 11:53 am     Reply with quote

i have been playing around with FPGA's lately and love the simplicity of state machines in VHDL. is there an easy way to do a state machine design using a PIC micro? what would the format look like?

thanks
bfemmel



Joined: 18 Jul 2004
Posts: 40
Location: San Carlos, CA.

View user's profile Send private message Visit poster's website

State Machine Stuff
PostPosted: Fri May 13, 2005 12:33 pm     Reply with quote

buckeyes1997,

Here is little piece of code you can modify to make what you want.
Code:

/* State Machine */

   currentState = RESET;

while(TRUE)  {

   switch (currentState)    {
      case RESET:
         /* do setup and reset stuff */
         currentState = STATE1;
         break
      case STATE1:
         /* do things for this State */
         if (Something_Happens) {
            /* do stuff */
            currentState = nextState;
         }
         break
      case STATE2:
         /* do things for this State */
         if (Something_Happens) {
            /* do stuff */
            currentState = nextState;
         }
         break
      case STATE3:
         /* do things for this State */
         if (Something_Happens) {
            /* do stuff */
            currentState = nextState;
         }
         break
      case STATE4:
         /* do things for this State */
         if (Something_Happens) {
            /* do stuff */
            currentState = nextState;
         }
         break
      default:
   }   
}   

Good Luck
- Bruce
buckeyes1997



Joined: 12 May 2005
Posts: 15

View user's profile Send private message

awesome
PostPosted: Mon May 16, 2005 7:36 pm     Reply with quote

awesome thanks
anyone else have a template or anything to add? have you used the code provided.
matt
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