Reply by rtstofer December 20, 20122012-12-20
> My suggestion would be to check the co-operative scheduler included and
> explained in this free ebook
> http://www.tte-systems.com/books/pttes
>
> The scheduler is written in C and can be easily ported to any mcu, all
> you need to change is the interrupt handler to match your device.
>
> I doubt that your project needs a pre-emptive RTOS, I'm not even sure if
> you actually need any OS.
>
> Alex

I have that book! Unfortunately, I have the hardback costly version... Free is so much better!

I used the scheduler for a PIC project several years ago and it worked out fine.

If individual tasks can be broken up into tiny morsels and the code written as a state machine versus a time consuming loop, cooperative multitasking works well. Loops like the following don't work well for this type of scheduling:

while (<wait for some condition>) {
;
}
<do something>

but something like this will:

void Task1(void)
{
switch(state) {
case WAIT: if (<some condition>) state = DO; break;
case DO: <do something>; state = WAIT; break;
}
}

In the SuperLoop just call Task1 from time to time.

while (1) { // SuperLoop
Task1();
...
...
}

Obviously, there are a bunch of details missing...

Richard

An Engineer's Guide to the LPC2100 Series

Reply by Alexan_e December 20, 20122012-12-20
On 12/19/2012 07:26 AM, preethamreddy1989 wrote:
>
> hello friends i need a rtos program to run 3 task
> 1.task should measure the value (ade7757)
> 2.it should display on lcd
> 3.it should send data to zigbee
>
> can anyone give me idea how write the program
> .

My suggestion would be to check the co-operative scheduler included and
explained in this free ebook
http://www.tte-systems.com/books/pttes

The scheduler is written in C and can be easily ported to any mcu, all
you need to change is the interrupt handler to match your device.

I doubt that your project needs a pre-emptive RTOS, I'm not even sure if
you actually need any OS.

Alex
---------------------
http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx/122x microcontrollers )

Reply by rtstofer December 20, 20122012-12-20
--- In l..., "preethamreddy1989" wrote:
> hello "Donald H"
> i was asking how to start writing rtos not to write my porgram
>
> i want to know how to run 3 task simultaneously

Writing an RTOS is a REALLY BIG job. Take a look at the code in FreeRTOS for examples that run on the LPC2148.

Your application, as you describe it, doesn't appear to need an RTOS and there would be no advantage to using one for a sequential read-compute-write type of program. You can't 'write' until you have the results of 'compute' which is totally reliant on 'read'.

Tasks don't really run simultaneously on a single core processor.

Cooperative multitasking is a useful way to get the appearance of simultaneous execution. Most OSs like Windows use cooperative multitasking. Basically, each task surrenders its execution so other tasks get a chance to run. For example, a loop in a cooperative task might have a DoEvents() call while inside a tight loop.



For a simple read-compute-write type of program the loop looks the same:



Some people call this type of loop a SuperLoop because it gives every task a chance to execute in a round-robin scheme.

As I said, writing an RTOS is a REALLY BIG job. You'll need to do some research on this one. I would start with FreeRTOS...

Richard
Reply by FreeRTOS Info December 20, 20122012-12-20
On 20/12/2012 10:32, preethamreddy1989 wrote:
>
> hello "Donald H"
>
> i was asking how to start writing rtos not to write my porgram
>
> i want to know how to run 3 task simultaneously
> may be i m not too smart as of u in this programming but not too stupid
> like u to embrass others
>
> this group is to help others but not to show ur's intelligence

I think the group provides the best help to those who start by helping
themselves.

On the link below you will find a very basic demo that will run in a
simulator, so no hardware required. It probably makes a good starting
point if you are not familiar with running tasks in an RTOS.

http://www.freertos.org/simple-freertos-demos.html

There are also tutorial books that take you from the very basics to an
intermediary level, but this forum is not intended for commercial plugs,
so I will note that there are lots of books available that will do the
same thing for you.

Regards,
Richard.

+ http://www.FreeRTOS.org
Designed for microcontrollers. More than 7000 downloads per month.

+ http://www.FreeRTOS.org/trace
15 interconnected trace views. An indispensable productivity tool.
Reply by preethamreddy1989 December 20, 20122012-12-20
hello "Donald H"
i was asking how to start writing rtos not to write my porgram

i want to know how to run 3 task simultaneously
may be i m not too smart as of u in this programming but not too stupid
like u to embrass others

this group is to help others but not to show ur's intelligence
Reply by Donald H December 19, 20122012-12-19
--- In l..., "Kevin" wrote:
>
> I assume that this is for some kind of school project.

You are correct !

> In which case I would suggest that you would just try it first.
>
> Communities respond best to specific (technical) questions and not to questions such as "write my code please". I'm sorry to say it but that is what your question looks like.

The OP is from India( preethamreddy1989 is a typical name ) .

What did you expect ?

He will drop out and let the real engineers from India shine.

don
Reply by dave...@maildr.us December 19, 20122012-12-19
Here it is:

while( 1 )
{
measure();
display();
send();
pause();
}

DaveS
Reply by Kevin December 19, 20122012-12-19
I assume that this is for some kind of school project.
In which case I would suggest that you would just try it first.

Communities respond best to specific (technical) questions and not to questions such as "write my code please". I'm sorry to say it but that is what your question looks like.

--
Kevin
Reply by roelof 't Hooft December 19, 20122012-12-19
On Wed, 2012-12-19 at 08:02 +0100, Bernardo Marques wrote:
> 3 ideas for you:
>
> 1 - write the code
> 2 - test it
> 3 - solve errors and bugs you might find.
>
> Hope it works.
>
> Regards,
> Bernardo Marques.

Better yet, hire one of the many helpful persons on
this list (and pay him/her) to write the code for you.

roelof
Reply by Bernardo Marques December 19, 20122012-12-19
3 ideas for you:

1 - write the code
2 - test it
3 - solve errors and bugs you might find.

Hope it works.

Regards,
Bernardo Marques.