Discussion in "8051 Discussion Forum" started by    Amit Kumar Das    Sep 24, 2010.
Fri Sep 24 2010, 06:58 am
#1
Is there any easy to use, available RTOS to implement in 8051(AT89S52) ?
Fri Sep 24 2010, 08:36 am
#2
is RTOS means Real Time Operating System
Fri Sep 24 2010, 12:37 pm
#3
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
#4
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
Sat Sep 25 2010, 05:28 am
#5
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
#6
Hai Ajay,Can you brief us more about the "state machine way of coding" and any related articles of study on that.

Regards
Sainath
Sun Sep 26 2010, 03:33 am
#7
Read the txt file regarding state machine.
Sun Sep 26 2010, 03:40 am
#8
Sorry the attachment was not attached due to error.
Sun Sep 26 2010, 03:43 am
#9
Ajay Sir,

Can you post some example written in Keil C using state machine for S52 microcontrollers.
Tue Sep 28 2010, 02:36 am
#10
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
 Amit Kumar Das like this.
Tags state machine embedded system8051 state machine codingmultitasking through state machines

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

EdwardFew
Mon Mar 18 2024, 01:14 pm
EmeryPah
Mon Mar 18 2024, 11:51 am
RobertMax
Sun Mar 17 2024, 10:22 pm
DanielJar
Fri Mar 15 2024, 06:52 pm
Tuzaimecor
Fri Mar 15 2024, 02:32 am
PromotionFoode
Thu Mar 14 2024, 08:11 pm
EdwardGeawn
Sun Mar 10 2024, 12:24 pm
ZacharyShado
Sat Mar 09 2024, 10:04 am