Page 1 of 1

Diminishing stack

Posted: 25 May 2010, 14:29 PM
by FFMan
Don

I have some code (a task) that read GPS data at 57600 on a zx24p using com2. Its configured to send 4 RMC records a second at the moment. The first part of the code waits for a satellite lock before carrying on.

The block of code that reads the data loops round if there is no lock. I am getting a program hang after a period of a few secs. If i double the stack size the code runs for longer. At the moment I have a 1000 byte stack which allows the code to run long enough to get a lock but clearly there is something amiss.

Strangely once a lock is acheived the same block of code works fine. By inserting debug.print system.taskheadroom, i can see in 'no lock mode' the usable stack is decreasing by 2 bytes every loop.

The code is pretty straight forward, the only 'naughty' is a goto that jumps out of the middle of a select case block when waiting for a lock. What do you think is causing my issue ? What sort of coding causes this ?

thanks

Re: Diminishing stack

Posted: 25 May 2010, 14:50 PM
by dkinzer
FFMan wrote:Strangely once a lock is acheived the same block of code works fine. By inserting debug.print system.taskheadroom, i can see in 'no lock mode' the usable stack is decreasing by 2 bytes every loop.
It is important to note that System.TaskHeadRoom does not tell you the amount of stack space that is left at any point in time. Rather, it indicates the most stack space that was used up to the point when the headroom value was taken.
FFMan wrote:What sort of coding causes this ?
It could be related to the way that you coded the routines but it could also be an issue with the code generated by the compiler. There is really no way to determine the cause without seeing the code. If you'd rather not post it here, zip up all of the source files and the project file and email it to me.

Posted: 26 May 2010, 8:33 AM
by FFMan
have sent you the code to your email address