Some questions..

willywortel wrote on Monday, February 09, 2009:


First of all, thanks again for all your support so far. I really liked it.
Tomorrow I’ve my first milestone, then I’ve to present my boss the software that I have already.
I managed to get the OS quite stable, but I had to remove some things for it :(. For example the RS232.

I am now already spending three days to find the unpredictable behavior of the OS when integrating the RS232, interrupt based. I`m a bit clueless, I did all the things I could find on the website and more.

Random freezes of the OS when using the RS232 task.

PIC32 port with multi vector interrupts
Using MP-LAB IDE with Microchip compiler
Running total of 7 tasks:
- Display gatekeeper Task
- SPI Task
- RS232 Task( actually RS485 )
- KeypadTask
- Menu Task
- Task manager (the one that spawns all the tasks)
- Analog to digital

Different tasks can get each other data by using the defined functions like getAdc, setSpi, etc. Every get/setter is protected by a Mutex or Queue.

What did I try:

See if it is not a stack overflow by using the method 2. Unfortunately this macro doesn’t work for me. I don’t know if it is a processor specific thing. When I paste the prototype and function in the main, it will never gets executed. I tested this by stripping down a task stack to a known value where it should overflow. Nothing happened.

So I tried a piece of my own. I created a function like this:

    if( uxTaskGetStackHighWaterMark( NULL ) < 100 )
        // not enough stack :frowning:

And called it in every task. Since I’ve put a breakpoint in the while, I get noted if a task has less than 100 stack left (I know, this is much. But for the debug only).
No task gets here, so I assume that every task has enough stack. (May i assume this?)

With the MPLAB Real-Ice i checked many status registers when the OS freezes. Like some status from peripherals from SPI / RS232, but found nothing special. I see that the Timer1 is still incrementing. But no other task gets executed any more when a freeze happens.

What I did not yet tried is to use the trace utility. That is because I do not yet own a Logic Analyzer. I will order this somewhere this week, so i hope this will help to solve more.

Does anyone have any idea’s where I can look for now? I am really clueless =(.
This is my first OS and I really like it. I`m also introducing it on my work and there is a high change that they will use it in the feature. So I then hope to switch quickly to the commercial variant (for some real support :slight_smile: )

Hope someone can give me some advice, thanks.

alys_merk wrote on Monday, February 09, 2009:

i m not a master in this rtos, but have some experience in rtos architecture…may be my thoughts would be useful.
1. check if you have timer interrupts, because scheduler is driven from this source.
If you can see facts of calls oo scheduler code periodically, then you must to understand why your tasks are not switched.
It can be because
-you are in infinite loop in highest priority code of your programm
-you have disabled task switching via some ‘critical section’ and forgot to enable it, or are in look in this guarded region.
if your some of your stack is broken - usually it hangs the software. do your stack greater for a test.
It seems there is smth wrong in your ISR dedicated to RS, or in task which handle its data. What about its priority? Try for a while make it lower.

alys_merk wrote on Monday, February 09, 2009:

***-you have disabled task switching via some ‘critical section’ and forgot to enable it, or are in look in this guarded region.***
are in LOOP in this guarded region.

also an advice - try to not "play in priorities" in your task.
better to have - "user priority" and "runtime priority". Do not use if possible, - higest priority, the system gives to you.
When your system consists of tasks with different, "well tuned" priorities - usually it means that it is wrong implemented, or hardware is feeble for your project.