Pumpkin, Inc.

Pumpkin User Forums

Strange Behaviour of OSSched()

For issues specific to TI's MSP430 line of ultra-low-power microcontrollers, including compilers (e.g. Quadravox AQ430), IDEs (e.g. IAR Embedded Workbench) and development tools (e.g. TI MSP-FET430 Flash Emulation Tool).

Strange Behaviour of OSSched()

Postby Patroclos » Wed Sep 06, 2006 1:13 am

Hi,
I have compiled and executed the tutorials came with Salvo. I have included salvo source files rather than using already built libraries. However when the execution begins, after a certain amount of cycling between the tasks, program execution returns back to the beginning of main(). It also reinitializes my global variables(sets them to zero) but never executes tasks again.
For example the code of tutorial 3; I have compiled it and it worked fine. Even LED blinked a few times but after TaskCount() task is executed for 11 times program returned back to Init() - back to the begining of main()! I have changed the number of tasks but again after a certain amount of execution for each task, program return back to main. After returning to main() it can never execute the tasks again so the program loops infinitely in main() as if I have written an inifite for loop including all the code in main()
Why is that happening, do anyone have any idea?
Thanks

------------------
Taskin

Taskin
Patroclos
 
Posts: 4
Joined: Tue Sep 05, 2006 11:00 pm
Location: Istanbul / Turkey

Re: Strange Behaviour of OSSched()

Postby aek » Wed Sep 06, 2006 6:29 am

1. Did you follow http://www.pumpkininc.com/ubb/Forum19/HTML/000027.html ?

2. This sounds like having the wrong interrupt table for the particular part. Make sure that your are including the proper header file for the part you are using -- e.g. for an MSP430F169, you must include msp430.h or msp430F16x.h, and nothing else.

3. Could also be a WDT issue, but the tutorials are builot to deal with that properly.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Strange Behaviour of OSSched()

Postby aek » Wed Sep 06, 2006 6:37 am

You mention tu3 -- which doesn't use interrupts. For apps that use interrupts, another common mistake is to forget to include the code module that has the ISR. When an interrupt occurs, the code vectors to la-la land and you crash.

What happens if you load one of the pre-existing projects instead of building your own?

Also, need to know which compiler you're using, and please show your salvocfg.h.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Strange Behaviour of OSSched()

Postby Patroclos » Thu Sep 07, 2006 6:10 am

I have tried the changes you have mentioned in the link, but they didn't solve the problem. But now program execution acts as if it starts from the begining each time. I mean, it loops between tasks then returns back to Init() - code is below - then again loops between tasks and returns again to Init etc. Before, it didn't loop between tasks after it returned to Init once. but now it does.
by the way, the code is taken from tut5. I have just added a taskCounter to see how many times the task is executed. I have also added the isr.cpp file given in folder tut1 to project but it didn't work either. should I add another interrupt table for OSTimer()?

The code is below:

#include "main.h"
#include "salvo.h"

#define TASK_COUNT_P OSTCBP(1) /* task #1 */
#define TASK_SHOW_P OSTCBP(2) /* "" #2 */
#define TASK_BLINK_P OSTCBP(3) /* "" #3 */
#define PRIO_COUNT 10 /* task priorities*/
#define PRIO_SHOW 10 /* "" */
#define PRIO_BLINK 10 /* "" */
#define BINSEM_UPDATE_PORT_P OSECBP(1) /* binSem #1 */

unsigned int counter, taskCounter;

_OSLabel(TaskCount1)
_OSLabel(TaskShow1)
_OSLabel(TaskBlink1)

void TaskCount( void )
{
for (; {

if ( !(counter & 0x000F) )
OSSignalBinSem(BINSEM_UPDATE_PORT_P);

taskCounter++;
OS_Yield(TaskCount1);
}
}

void TaskShow( void )
{
for (; {
OS_WaitBinSem(BINSEM_UPDATE_PORT_P, OSNO_TIMEOUT, TaskShow1);

PORT = (PORT & ~0xFE) | ((counter >> 8) & 0xFE);
OS_Yield(TaskShow1);
}
}

void TaskBlink( void )
{
InitPORT();

for (; {
PORT ^= 0x01;

OS_Delay(50, TaskBlink1);
OS_Yield(TaskBlinkl);
}
}

void main( void )
{
Init();

OSInit();


OSCreateTask(TaskCount, TASK_COUNT_P, PRIO_COUNT);
OSCreateTask(TaskShow, TASK_SHOW_P, PRIO_SHOW);
OSCreateTask(TaskBlink, TASK_BLINK_P, PRIO_BLINK);

OSCreateBinSem(BINSEM_UPDATE_PORT_P, 0);

counter = 0;

OSEi();

for (;
OSSched();
}

and the configuration file is:

#define OSBYTES_OF_DELAYS 1
#define OSENABLE_IDLING_HOOK TRUE
#define OSENABLE_BINARY_SEMAPHORES TRUE
#define OSEVENTS 1
#define OSTASKS 3

I'm using Crossworks 1.4(sorry for forgetting to mention about the compiler). About WDT, I have read in the manual that as long as OSSched() is called, watchdog timer is resetted. So there shouldn't be a problem with it I think.

Thanks,

------------------
Taskin

Taskin
Patroclos
 
Posts: 4
Joined: Tue Sep 05, 2006 11:00 pm
Location: Istanbul / Turkey

Re: Strange Behaviour of OSSched()

Postby Patroclos » Thu Sep 07, 2006 6:22 am

I have forgotten to mention about include startup code option in linker options. I couldn't find that option in linker menu however when I first tried to compile a salvo application before adding directories I have deleted all other directories in the project (including system files folder ). So the application didn't work and when I added it back it worked. is that option related with that folder?

thanks,

------------------
Taskin

Taskin
Patroclos
 
Posts: 4
Joined: Tue Sep 05, 2006 11:00 pm
Location: Istanbul / Turkey

Re: Strange Behaviour of OSSched()

Postby aek » Thu Sep 07, 2006 10:21 am

No, you do need that option enabled (with 1.3 at least).

1) Is isr.c part of your tut5 project?

2) how large is the CODE section of your project (use the Symbol Browser).

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Strange Behaviour of OSSched()

Postby Patroclos » Fri Sep 08, 2006 2:59 am

I couldn't find "startup code include" option, so it is in its default state(but I don't know whether it is enabled or disabled). Do we have to make any changes in that option in Crossworks 1.4? I mean is it disabled default so we have to change it?
By the way code is 1.4 KB and placed in addresses 1100 — 1699. In the symbol browser it also writes the same, between 1100 - 1699 and size is 1,434KB.
I have added the isr.c in the source files folder of project. just next to main.c

------------------
Taskin

Taskin
Patroclos
 
Posts: 4
Joined: Tue Sep 05, 2006 11:00 pm
Location: Istanbul / Turkey

Re: Strange Behaviour of OSSched()

Postby Meista » Wed Aug 13, 2008 7:12 am

What was finally the solution for the problem? I have a similar problem with ICC430 and Salvo.
Meista
 
Posts: 3
Joined: Tue Aug 12, 2008 11:00 pm

Re: Strange Behaviour of OSSched()

Postby aek » Wed Aug 13, 2008 7:24 am

Linker startup code has nothing to do with Salvo -- that's a tools issue. Usually, when you create a project in the IDE (e.h., CrossStudio or Embedded Workbench) the IDE inserts that startup code into the project.

Random-appearing restarts after some number of iterations through OSSched() is invariably one of two things that causes a reset:

1) Lack of a proper ISR for enabled interrupts (e.g. the interrupt happens, program vectors to the appropriate interrupt vector, but there's no code there, so you eventually reset). This can happen e.g. if you take tut5.c in Salvo v3 and forget to add the isr.c file that accompanies the project.

2) Failure to clear the watchdog timer, which will cause a reset.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Strange Behaviour of OSSched()

Postby Dave Hohl » Thu Aug 14, 2008 1:32 am

On the MSP430 another potential cause of a reset is accidentally writing to certain SFR addresses. This is usually due to a stray or uninitialized pointer. I have seen oscillator faults and NMIs generated because of spurious writes to an SFR.
Dave Hohl
 
Posts: 24
Joined: Wed Apr 02, 2008 11:00 pm
Location: Sunnyvale, CA, USA

Next

Return to TI's MSP430

Who is online

Users browsing this forum: No registered users and 1 guest

cron