RTOS template

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there,

How could I find an open source template RTOS project for IAR C compiler?
Is there anything free, just for beginners on this issue?

Thanks.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Google is your friend. When I first started looking at RTOS solutions, I Googled AVR and RTOS and ended up with quite a list. Several are open source.

I use FreeRTOS, but that can be overkill for the smaller AVRs. FreeRTOS has an IAR port for the ATmega323, but it easily portable to almost any of the mega AVRs. If you want to use the mega2560, I have some code in GCC format for that.

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hallo Stu,

Thanks for your support I bought some books like:
Born to code in C
Something for Embedded programming and
Something for Multytasking and RTOS

I have almost read the AVRFreaks article about this issue and I realy try to understand.

One of this books says that once you begin write your programs based on multytasking theory you don't want to write again as you wrote in the past. Is that real?

I would like to learn about the multytasking theory in practice and I really can't understand how things can work simultaneusly. Ok, I understand the switching from one task to another because of the tick but what could be happened if there were some input data from a
software Manchester protocol reader that cannot be stoped until thee read or time out(ed).

I mean how multytasking systems can work if there were some serious reasons make the task switching forbiden?

If you don't mind I would like to read and learn from your code.

Thanks.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

#1 google return for free rtos:

http://www.freertos.org/

Lot's of code and theory to read there.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, thank you guys.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

icarus1 wrote:
Born to code in C
Something for Embedded programming and
Something for Multytasking and RTOS
Ah yes. The classics. :wink:
icarus1 wrote:
One of these books says that once you begin write your programs based on multitasking theory you don't want to write again as you wrote in the past. Is that real?
Don't believe everything you read. As with any tool, there are right places and wrong places to use multitasking. Also, there are different forms multitasking -- pre-emptive, sequential, cooperative, and so on.
icarus1 wrote:
I would like to learn about the multitasking theory in practice and I really can't understand how things can work simultaneously. Ok, I understand the switching from one task to another because of the tick but what could be happened if there were some input data from a software Manchester protocol reader that cannot be stopped until thee read or time out(ed).

I mean how multitasking systems can work if there were some serious reasons make the task switching forbidden?

That's when you introduce the concept of a "critical section" -- a section or task that cannot be pre-empted until it is done. There are several ways to do this, depending on the RTOS. FreeRTOS allows you to define the priority of a task, so if the Manchester task priority is higher than anyone else, it will always win until you specifically "block" the task by either deleting the task or blocking on a semaphore or mutex.

Another way is what I hinted at above -- FreeRTOS allows you to mark a section of code (within a function) as "critical", which basically turns off the task scheduler until you exit the critical section.

Note that we are talking about the task scheduler scheduling another task and not other interrupts -- it's entirely possible for other interrupts to be happening in your critical section. That's a good thing; for example, your Manchester protocol reader might use an interrupt-driven routine to capture the data stream.

In fact, your protocol reader might be run entirely from the interrupt routine -- fill a buffer until you know you've read everything you need, then flag the Manchester decoder to do its thing. Now you don't need to "block" on the protocol reader. I'm not sure that this meets your application requirements, but it is a possibility.

icarus1 wrote:
If you don't mind I would like to read and learn from your code.
I recommend you first try the demo code that comes with whatever RTOS you want to use. Try it and understand it. As you have questions, post them as separate topics here. That way, others can learn from your questions and from the responses you get.

When you have questions, I heartily recommend you first do a search of the forum for keywords on your question. It's very likely it's been asked before, and answered. Also try Google -- these search engines (and the documentation! :wink:) are your friends!

Finally, if you really are starting out (as it appears you are), start with something simple and work up. Sometimes something as simple as getting your CPU to flash an LED can give you leg up on all sorts of things, as well as giving you confidence.

Stu

PS: don't fly too close to the sun, Icarus! :D

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ha ha. Ok, I will;;;

Yes, I am really on the begining on this issue and I am not affraid to say it. That's why I posted my questions.

The truth is that I have almost done a multytasking project (a PLC) using a Mega16, but I am not sure that this was a real multytasking program like YOU and the 3 BOOKS I bought, say.

I really would like to learn about this theory and use it in the right way.

Thanks for all your suggestions.

Michael.

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most PLc's i've used don't implement multitasking. The ladder interpreter works from start to finish, then starts again. Things like timers and serial comms are handled via interrupts, but that is the extent of the 'multitasking'.

As for the rest of it, Stu said just about all there is to be said. Remember the term RTOS generally refers to a preemptive task switcher with a scheduler that guarantees a minumum task switch time. You can have a pre-emptive task switcher (like Windows and Linux) but not be 'real time'. Some people claim a co-operative task switcher to be 'real time'! But be aware that pre-emptive task switching has its set of issues - memory hungry, extra cpu overhead and the need to ensure shared variables are acessed atomically. On small micros like the AVR, I usually use a co-operative tasking technique. But ,as Stu correctly states, a RTOS is but one technique.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The concept is can't be too important, i think. So, i'll learn sth. after i have mastered its concept or i'd rather not do it!