Jump to content
43oh

Code Composer studio and RAM usage


Recommended Posts

I'm testing Mahony's algorithms for attitude estimation and I'm using a Launchpad with a MSP430g2553. In the code I'm using there are two functions; one calculate the attitude from accelerometer and gyro data (IMU) and the other one add magnetometer data (AHRS).

I tested first the IMU and worked OK.

Then I tested the AHRS and I couldn't make it work. What I could find through debugging was this:

In the top of the program there are four variables q0=1, q1=0, q2=0 and q3=0 and in the algorithm there is a sqrt() function, it seems that for some reason the sqrt() function overwrite the values in q0, q1, etc. As the algorithm use then those values the final values is of course wrong.

I then tried the program with AHRS in a MSP-EXP430FR5739 and it worked OK.

According to CCS the Memory Allocation in the MSP430G2553 is RAM=344 FLASH=12.354

and in the MSP430FR5739 is RAM=518 FLASH=13.034.

 

It seems that the code need 518 bytes of RAM, higher than the 512 of the MSP430G2553, I asume that's the issue, correct?

If is that, why CCS shows only 344 bytes used? Is there some way to know when I'm running out of RAM (other than the thing don't working...)? some way to see it in CCS?

Link to post
Share on other sites

The FR5739 has a hardware multiplier and the G2553 doesn't.

 

That could account for the difference in RAM usage?

I wasn't using the HM. I enable it now and the code seems to use the same amount of memory. The execution is faster, from aprox. [90]ms to 13[ms] (@default DCO = ~625 KHz)

Link to post
Share on other sites

The compiler generates a .map file which contains detailed information about memory allocation. You find it in the Release or Debug folder.

That file shows the same values that I see in the Memory Allocation.  The thing is why it shows me only 344 bytes, from that I get that I still have RAM to do other things...

Link to post
Share on other sites

If the overwritten variables are towards the end of the memory map, this indicates that your stack grows too big. If the overwritten variables are locally declared in a function, this can also indicate that your stack grows too big, i.e. starts to overlap with global variables.

 

Variables declared locally (e.g. within a function) are allocated dynamically on the stack and won't show up in the map file. Stack space is also used to temporarily save registers during function calls. Complex functions like sqrt probably use quite some space to save temporary results.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...