RTOS
Discussion in "8051 Discussion Forum" started by Amit Kumar Das Sep 24, 2010.
Fri Sep 24 2010, 06:58 am
Is there any easy to use, available RTOS to implement in 8051(AT89S52) ?
Fri Sep 24 2010, 12:37 pm
Ya I think RTxtiny .I dont have keil installed,you can check in that help topics you will find it there . Or google free rtos you will get it at free rtos site .
Sat Sep 25 2010, 12:42 am
its hard to use a kernel in 8051. 8051 is too small for a kernel type system.
I suggest to use state machine way of coding for best and faster working applications. you can also write state machines to mock multitasking
I suggest to use state machine way of coding for best and faster working applications. you can also write state machines to mock multitasking
Sat Sep 25 2010, 05:28 am
Is there any state machine software (with documentation and example) available for 8051 which can be interfaced to keil like QDK ?
Sat Sep 25 2010, 10:28 am
Hai Ajay,Can you brief us more about the "state machine way of coding" and any related articles of study on that.
Regards
Sainath
Regards
Sainath
Sun Sep 26 2010, 03:43 am
Ajay Sir,
Can you post some example written in Keil C using state machine for S52 microcontrollers.
Can you post some example written in Keil C using state machine for S52 microcontrollers.
Tue Sep 28 2010, 02:36 am
Its simple to implement, I will see if i can make a working example to put up on forum but for now just understand the logic.
You will have a variable that will hold the state of system.. say SysState. and there are few states depending on tasks your system is going to do..
simple example:
A task for keypad, LCD and an RTC.
Task1: Check for key and show time stamp on LCD when key is pressed
Task 2: Update Datetime on LCD
Task 3: process interrupted event (make a GPIO high/Low)
Possible SysStates:
A> Check key
B> Key Detected
C> Read RTC
D> Update LCD
E> Event Process
then a simple switch case statement in while(1) loop does the job..
switch(SysState){
case CheckKey:
//check if key pressed or not
//change state here if needed
break;
case ReadRTC:
//read rtc here
//change state here if needed
break;
//and so on...
}
Remember its always recommended not to spend too much time in ISR, coz you may miss other interrupts or interrupts may get delayed for a longer time. so State machine approach gives us this facility not to spend too much time rather you can simply change the state of your system to Interrupt.. and process that interrupt in main loop.
There is no/very less while loops in state machines, simple if conditions so that state machine is always in running mode never stops.
you can make use of multiple statemachines to mock up multitasking..
lets say
State machine 1: SystemState (Task1, Task2, Task3)
State machine 2: TaskState (Tas1state, Task2State, Task3State)
then each task1state may have sub states..
so whenever system state changes to a new task, you processor without a need of context switch starts executing code for it. for changing systems state you can make use of a timer which is fired at a fixed interval of time.
Hope you get an idea now
You will have a variable that will hold the state of system.. say SysState. and there are few states depending on tasks your system is going to do..
simple example:
A task for keypad, LCD and an RTC.
Task1: Check for key and show time stamp on LCD when key is pressed
Task 2: Update Datetime on LCD
Task 3: process interrupted event (make a GPIO high/Low)
Possible SysStates:
A> Check key
B> Key Detected
C> Read RTC
D> Update LCD
E> Event Process
then a simple switch case statement in while(1) loop does the job..
switch(SysState){
case CheckKey:
//check if key pressed or not
//change state here if needed
break;
case ReadRTC:
//read rtc here
//change state here if needed
break;
//and so on...
}
Remember its always recommended not to spend too much time in ISR, coz you may miss other interrupts or interrupts may get delayed for a longer time. so State machine approach gives us this facility not to spend too much time rather you can simply change the state of your system to Interrupt.. and process that interrupt in main loop.
There is no/very less while loops in state machines, simple if conditions so that state machine is always in running mode never stops.
you can make use of multiple statemachines to mock up multitasking..
lets say
State machine 1: SystemState (Task1, Task2, Task3)
State machine 2: TaskState (Tas1state, Task2State, Task3State)
then each task1state may have sub states..
so whenever system state changes to a new task, you processor without a need of context switch starts executing code for it. for changing systems state you can make use of a timer which is fired at a fixed interval of time.
Hope you get an idea now
Amit Kumar Das like this.
Tags state machine embedded system8051 state machine codingmultitasking through state machines
Powered by e107 Forum System