Case Study: Myke Predko's RTOS

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Case Study: Myke Predko's RTOS

Postby Brian Griffin » Sun Feb 26, 2012 1:14 pm

From the Myke Predko's "Programming and Customizing the PIC Microcontroller", one of the topics which caught my attention is the RTOS/Multitasking chapter which is inside the book.

However, most of the content in the topic and in the book are already dated and no mentions of newer microcontrollers are there, so wading through the assembly codes are downright painful and difficult.

To improvise on his RTOS program which is his "Digital Clock and Thermometer", I used OSA RTOS : http://www.pic24.ru/doku.php/en/osa/ref/intro which is for the Hi-Tech PICC16/18, MikroE and MPLAB C18. I placed his routines carefully into each tasks formed.

The rest of his project in another RTOS are done well, except for the thermometer part. His thermometer is a DS18S20, and there are no mentions of how this one-wire emulation will affect the whole RTOS. Emulating a bus or an interface in a RTOS task isn't easy and it may corrupt readings if done improperly. I got a nasty fluctuating readings from +127 degrees celsius and some erroneous readings.

So, I tried to let the reading of DS18S20 to be a "critical task" which is to temporarily halt the RTOS, the timers and stuff to perform that particular task, and when it is done, the system continues the RTOS as usual. But this has a very bad drawback - the clock is being 14 minutes late due to this one interrupting the digital clock task.

Another practical way is to use a hardware UART to send/receive data to/from the DS18S20, and ditching the emulated bit-banged 1-wire immediately. By this way, there will be (probably) no or less chances the RTOS being stalled. I have yet to test this due to the absence of the open-drain buffer (it requires that for UART).

If I have made it working, I will write a sample code in MPLAB C18, Hi-Tech PICC16 and also for the MikroC.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: Case Study: Myke Predko's RTOS

Postby kl84 » Mon Feb 27, 2012 10:49 am

Interesting...thanks for the sharing...
User avatar
kl84
Amateur
 
Posts: 166
Joined: Thu Jul 08, 2010 12:14 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 7 guests

cron