Pumpkin, Inc.

Pumpkin User Forums

OS_Delay() or stack problem

If you can't make Salvo do what you want it to do, post it here.

OS_Delay() or stack problem

Postby samuel » Wed Nov 08, 2006 10:43 am

I am troubleshooting what I believe is a stack problem. When I call OS_Delay() my MSP430 is resetting. I single stepped through the function and I found that when the program tries to task switch (in the salvoportra430.asm, _OSCtxSw it jumps into an unknown memory address and runs there until reset. I found that declaring some variables as static (that I'm sure don't need to be static) corrects the problem. I'm open to suggestions on where to start troubleshooting. In reading the Salvo manual I believe I found a discrepancy. On p. 459 the manual says to check the return values of OSInit() for errors, but on the p. 310 the description OSInit() says the function is void.
samuel
 
Posts: 22
Joined: Sun Oct 08, 2006 11:00 pm

Re: OS_Delay() or stack problem

Postby aek » Wed Nov 08, 2006 10:54 am

quote:
I found that declaring some variables as static (that I'm sure don't need to be static) corrects the problem.
In the Salvo User Manual (see the Reference chapter), local (auto) variables are not presevred across task switches. Let's see the task that it's crashing in.

Also be sure you have all the patches applied.

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

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

Re: OS_Delay() or stack problem

Postby aek » Sun Nov 19, 2006 1:09 am

quote:
In the Salvo User Manual (see the Reference chapter), local (auto) variables are not preserved across task switches.
Failing to declare any variables (arrays, pointers or others) as static from within a task will nearly always cause the problems you describe.

If you have only one task, then maybe it won't happen, but as system complexity goes up, the odds of it biting you go up exponentially.

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

[This message has been edited by aek (edited November 19, 2006).]

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

Re: OS_Delay() or stack problem

Postby samuel » Sun Nov 19, 2006 11:21 am

Here's what was causing the resets. Not declaring arrays and pointers as static. When a pointer is put on the stack and the there is task switch, the contents of the pointer (an address) get overwritten. If the value that gets put back in to the pointer is not in RAM, and you attempt to write to the invalid address you get a reset. Because of the way the compiler implements arrays, the same is true for an array.
samuel
 
Posts: 22
Joined: Sun Oct 08, 2006 11:00 pm


Return to Coding

Who is online

Users browsing this forum: No registered users and 3 guests

cron