Jump to content

Wire.h excessive RAM usage ? - G2553

Recommended Posts


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 ?


Link to post
Share on other sites
  • 3 weeks later...

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.

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

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.

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.

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