Pumpkin, Inc.

Pumpkin User Forums

Static arrays in tasks

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).

Static arrays in tasks

Postby Meista » Thu Nov 06, 2008 4:24 am

I have a strange problem with arrays in salvo tasks.

The salvo manuals cleary says that if information should be stored during a context switch, the variables must be defined as static.
On the other hand if the value is not needed, it doesn't have to be static.

In my application I have to handle large character arrays (e.g. 150 bytes) in the tasks. If I define them as static everything works fine. But if they are not static, the msp430 has very strange behavior if the array size is bigger than 125 bytes(resets or locks during operation etc.)

I am using the MSP430 F1611 with the CrossStudio 1.4 and Salvo 4 pro.

Has anyone an idea?

Meista
 
Posts: 3
Joined: Tue Aug 12, 2008 11:00 pm

Re: Static arrays in tasks

Postby aek » Thu Nov 06, 2008 6:26 am

You're probably overflowing the stack, or the declaration is really giving you a 125-_word_-size array, which violates Salvo's spec for the MSP430 (see the Salvo compiler reference manual RM-RA430.PDF).

One thing to keep in mind is that you ultimately are using the same maximum amount of RAM whether you declare this large array as static or as an auto variable, assuming there is no other auto variable usage that's bigger.

If static, it's obviously always present. If auto, it's present only when the task runs, but it still pushes the SP down by the size of the array, and you need to write for / test for proper operation when the stack is that large.

So, overall, it doesn't make much difference in terms of how much RAM it costs you, so it's not much of a "penalty" to keep it static.

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

[This message has been edited by aek (edited November 06, 2008).]

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

Re: Static arrays in tasks

Postby aek » Thu Nov 06, 2008 6:39 am

Just to be clear -- a 125-_word_-size array in a Salvo task with CW430 as th compiler yields 250 bytes of auto variables. The limit (see RM-RA430.PDF) is 255, so if you task had another 6 bytes of auto variables, you would see problems.

IOW, Salvo maintains an 8-bit local stack frame pointer with RA430.

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

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

Re: Static arrays in tasks

Postby aek » Thu Nov 06, 2008 6:51 am

Note also that compilers also may use a function's local stack space when performing certain operations, thereby further enlarging the function's stack frame, unbeknownst to the user.

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

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


Return to TI's MSP430

Who is online

Users browsing this forum: No registered users and 4 guests