Trouble converting an Energia sketch


I have just recently started to use PlatformIO and am really liking it, i have converted an Arduino Due sketch and it worked flawlessly.

I also have an Energia sketch that I would like to convert and continue developing in PlatformIO.
But I ran into some build errors at once, mostly concerning the SPI library.
It seems that PlatformIO uses an older version of the framework. Is there a plan to update it?

I tried using a newer version of the framework from github with the correct version of the SPI library but ran into other build errors.

I used this to get the newer version of the framework:

platform_packages =
framework-energiamsp430 @

and this was the error I got:

fatal error: msp430f5xx_6xxgeneric.h: No such file or directory

The file is in DriverLib/utility/inc and the include paths all seem ok but I seem to be missing something.

Any assistance would be welcome :slight_smile:

Full platformio.ini is what exactly?

Open an issue on Issues · platformio/platform-timsp430 · GitHub.

Well if it’s not found the include paths are not ok. The lilbrary does not adhere to the library structure , so utility/inc is not added by default to the include search path.

However the normal include path should be through just #include <driverlib.h>. This includes pmm.h which includes hw_memmap.h which includes msp430f5xx_6xxgeneric.h. So you shuold just #include <driverlib.h> and have your needed header file. Or do it the lengthy way and #include <utility/inc/msp430f5xx_6xxgeneric.h>.

Full platformio.ini:

platform = timsp430
board = lpmsp430f5529
framework = arduino
platform_packages =
  framework-energiamsp430 @

lib_deps =

lib_extra_dirs =

The reason I said the include paths seem ok is that if I build with the normal timsp430 framework then it finds the file even though it is in the same path and the include arguments to gcc are identical. But I guess the file and include structures are more different than I first thought which would also explain why it only finds 22 libraries with the git repo I was hoping would work. It finds 31 with the regular timsp430.

So I guess a way forward is to either fork the repo and make it compatible with PlatformIO or to change the way I use the SPI library, alternatively see if I can add the changes to the SPI library that I need and use my own version of it.

And here I was hoping for a quick fix :slight_smile:

Okay, back to the beginning. Can you provide a minimal project for when the SPI lib works as intended and when there’s an error?

The problem was that I was getting build errors like this:

error: no matching function for call to 'SPIClass::transfer(byte [3], int)

So I compared the SPI library in the energiamsp430 framework with the one in the latest version of Energia and saw that they differed quite a bit. This was when I tried to update it to the latest version I could find of the msp430 library.

A simple example would be:

#include <Energia.h>
#include <SPI.h>

void setup()

void loop() 
    byte cmd[] = {0b00000001, 0x00, 0x00};
    digitalWrite(SS, LOW);
    SPI.transfer(cmd, 3);
    digitalWrite(SS, HIGH);

This compiles fine in Energia but not in PlatformIO.

I could just rewrite the code to fit the old version of the library but I would much rather prefer to use the newest libraries available.

The problem was resolved by using the latest update of the msp430 framework found here:

Thank you. :slight_smile:

1 Like