HI all, I am trying to implement a 8051 based RTOS. Now I have to write a context switch function. I think that , copying all the neccesarry registers without pushing on to the stack works , do you think is this a good idea? Also what stack size is suitable for my RTOS ? (I think 64 byte is ok) If anyone write an 8051 based RTOS can you give me suggestions please?
8051
Started by ●February 1, 2006
Reply by ●February 1, 20062006-02-01
"zibidi" <onurakdemir1@gmail.com> wrote in message news:1138815558.688313.268900@g49g2000cwa.googlegroups.com...> HI all, > I am trying to implement a 8051 based RTOS. Now I have to write a > context switch function. > I think that , copying all the neccesarry registers without pushing on > to the stack works , do you think is this a good idea? > Also what stack size is suitable for my RTOS ? (I think 64 byte > is ok) > If anyone write an 8051 based RTOS can you give me suggestions > please?Take a look at the FreeRTOS.org Cygnal (Sillicon Labs) port. The source code can be downloaded. http://www.FreeRTOS.org
Reply by ●February 1, 20062006-02-01
zibidi <onurakdemir1@gmail.com> wrote:> HI all, > I am trying to implement a 8051 based RTOS.Why? What are your requirements? Preemptive or cooperative? New, or a port of an existing OS? FreeRTOS has been ported to the 8051, so unless it's a s*h**l p*oj**t, why not use that?> Now I have to write a > context switch function.You mean you know how to do all of the OS... apart from the most important bit ;)> Also what stack size is suitable for my RTOS ? (I think 64 byte > is ok)Depends on your application tasks and their usage. Only you can say.> If anyone write an 8051 based RTOS can you give me suggestions > please?The 8051 is a target that most RTOS vendors avoid, with good reason. Hell, we've ported an RTOS to the PIC18, but even we weren't mad enough to consider the 8051. I certainly wouldn't do it for fun. pete -- pete@fenelon.com "there's no room for enigmas in built-up areas" - HMHB.
Reply by ●February 1, 20062006-02-01
Pete Fenelon wrote:> The 8051 is a target that most RTOS vendors avoid, with good reason. > Hell, we've ported an RTOS to the PIC18, but even we weren't mad enough > to consider the 8051. I certainly wouldn't do it for fun. >I would have thought the PIC18 would have even worse than the 8051. Ian
Reply by ●February 1, 20062006-02-01
zibidi wrote:> HI all, > I am trying to implement a 8051 based RTOS. Now I have to write a > context switch function. > I think that , copying all the neccesarry registers without pushing on > to the stack works , do you think is this a good idea? > Also what stack size is suitable for my RTOS ? (I think 64 byte > is ok) > If anyone write an 8051 based RTOS can you give me suggestions > please?Have a look here: http://www.8052.com/users/redtommo/realtime.html Ian
Reply by ●February 1, 20062006-02-01
Ian Bell wrote:> Pete Fenelon wrote: > > > The 8051 is a target that most RTOS vendors avoid, with good reason. > > Hell, we've ported an RTOS to the PIC18, but even we weren't mad enough > > to consider the 8051. I certainly wouldn't do it for fun. > > > > I would have thought the PIC18 would have even worse than the 8051. > > IanThat would have been my thought as well.
Reply by ●February 2, 20062006-02-02
Hi I've designed and used a minimal RTOS for the last 15 years I call it RTE51 (Real Time Executive). Because of the way that it is used, it is fairly immune to latch ups. It can execute up to 8 task preemptively . I use register bank 0 for all the tasks, this leaves the other register banks free for interrupts. This however means that I have to copy the contents of register bank 0 to xram during context switching. This adds some latency to the context switching but it saves a tremendous amount of stack space. I've originally used it with PL/M51 but changed it later to work with KEIL-C which I use extensively. A later change and experiment that I made was to add an additional layer that enabled me to put a task to sleep. These task can be woken after a certain time or after reception of a telegram. On the original version, once a task have been scheduled, it must execute till it is finished. Higher priority tasks can however preempt lower priority tasks which makes it preemptive. What might be of interest to you is how to get from an interrupt routine. As you know once you enter an interrupt routine on the 8051 a flag is set which prevents the 8051 from entering a same priority interrupt again. This flag is only reset once the iret instruction is executed but then control is passed back to the program from where it interrupted. With a RTE you would normally want to pass control to the executive after execution of an interrupt. The following snippet shows how to release the 8051 to again be able to interrupt while entering the scheduler and thus reducing latency: ;###################################################** ;* * ;* Call here from 'c' interrupt routines * ;* in order to execute tasks * ;* * ;###################################################** RteIntExecC: mov r1,#2 sjmp rie05 ;###################################################** ;* * ;* Call here from PL/M interrupt routines * ;* in order to execute tasks * ;* * ;###################################################** rte_int_exec_us1: rte_int_exec_us2: rte_int_exec_us3: mov r1,#4 rie05: clr ea ;dissable interrupt mov a,sp ;remove redundant stack clr c subb a,r1 mov sp,a mov a,#low rie10 ;restore the interrupt priority push acc mov a,#high rie10 push acc reti ;the interrupt is over rie10: clr c ;change to register bank 0 mov psw.4,c mov psw.3,c sjmp r_e05 ;regular task scheduler ;#############################################** ;* * ;* Call here from task or background * ;* * ;#############################################** RteExec: rte_exec: push acc ;save register PL/M style push b push dph push dpl push psw clr ea ;dissable interrupt . . ; this is where teh scheduler starts If you're interested, I can e-mail the assembler code to you. Regards Kobus
Reply by ●February 2, 20062006-02-02
yes I want it , it can be useful for me. I decide to implement a Round robin schedular with only 8 task as well. Also I think I am goint to use C , so I cant use register bank 0 also 1 as I see.(functions use them) zibidi
Reply by ●February 2, 20062006-02-02
zibidi wrote:> yes I want it , it can be useful for me. I decide to implement a > Round robin schedular with only 8 task as well. Also I think I am goint > to use C , so I cant use register bank 0 also 1 as I see.(functions use > them) > zibidizibidicigim neden 8051 kullaniyorsun. (Silicon labs in 100 mhz lik 8051 leri hari=E7) Yok illa RTOS yazacam diyorsan bisey demem de ama ARM kullansan freeRTOS ida port etmisler bak ne hos.. Zati C de yazacakmissin.. oh kebab yaa
Reply by ●February 2, 20062006-02-02
"tesla" <yusufilker@gmail.com> wrote in message news:1138872167.887306.287990@z14g2000cwz.googlegroups.com... zibidi wrote:> yes I want it , it can be useful for me. I decide to implement a > Round robin schedular with only 8 task as well. Also I think I am goint > to use C , so I cant use register bank 0 also 1 as I see.(functions use > them) > zibidizibidicigim neden 8051 kullaniyorsun. (Silicon labs in 100 mhz lik 8051 leri hari�) Yok illa RTOS yazacam diyorsan bisey demem de ama ARM kullansan freeRTOS ida port etmisler bak ne hos.. Zati C de yazacakmissin.. oh kebab yaa Couldn't have said it better myself... ?!?!? Meindert