Sign in to follow this  
Followers 0
B@tto

Wire.h excessive RAM usage ? - G2553

7 posts in this topic

Hi,

I just noticed an excessive consumption of ram by Wire on G2553 (I did not test on other µC) : 400 bytes !!

I took a look at Wire.h but can't find where this memory is used. 

If anyone can confirm this and/or have an idea about this issue ?

Regards

Share this post


Link to post
Share on other sites
  • Which framework?

I presume you're using Energia.

  • Which release of Energia?
  • Which release of the MSP430 boards package?

Share this post


Link to post
Share on other sites

Latest board package is 1.0.2 for MSP430.

If you dig into ~/Library/Energia15/packages/energia/hardware/msp430/1.0.2/libraries/Wire, you will see that the default I²C port on pins 9 and 10 is implemented with a software driver (twi_sw.c and twi_sw.h).

There are 2 buffers TwoWire::rxBuffer and TwoWire::txBuffer with size BUFFER_LENGTH = 16 (Wire.cpp and Wire.h).

For a more compact I²C library, but only on pins 15 and 16, use Energia 12.

Share this post


Link to post
Share on other sites

I'm using hardware i2c, and buffer size are the same, but it does not explain why it take so much RAM. Even 100 bytes would be rather normal, but 400 ?! That doesn't sound normal for me and I checked everywhere I don't see where this RAM is used

 

EDIT : I updated to 1.0.2 it's much better with around 200 bytes. I still can't explain this memory footprint with a buffer of 16 ( x 4 if I understand how the library works) so I a read the library, I would say that 100 bytes would be fare

Share this post


Link to post
Share on other sites

My understanding is that Energia will consume more resources than an equivalent program written in C using, for example, CCS.  Since Energia abstracts away some of the hardware details in favor of simpler programming, that abstraction consumes extra flash and ram.  Trying V12 of Energia as Rei Vilo suggested or moving to CCS would perhaps get the numbers down to what you are expecting/require for your application.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0