Problem
When trying to compile code for the MSP430 Experimental board (specifically the MSP-EXP430FR5739) in Energia version 0101E0017 the following error stream is presented:
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c: In function 'i2c_sw_init' :
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:43:16: error: 'TWISDA1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:43:16: note: each undeclared identifier is reported only once for each function it appears in
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:44:16: error: 'TWISCL1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c: In function 'i2c_sw_start' :
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:84:11: error: 'TWISDA1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:86:11: error: 'TWISCL1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c: In function 'i2c_sw_txByte' :
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:99:15: error: 'TWISDA1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:103:13: error: 'TWISCL1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c: In function 'i2c_sw_ack' :
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:122:12: error: 'TWISCL1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c: In function 'i2c_sw_rxByte' :
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:132:12: error: 'TWISDA1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:136:15: error: 'TWISCL1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c: In function 'i2c_sw_stop' :
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:157:11: error: 'TWISDA1' undeclared ( first use in this function )
C:\P rogram Files ( x86) \E nergia\h ardware\m sp430\c ores\m sp430\t wi_sw.c:159:11: error: 'TWISCL1' undeclared ( first use in this function )
The issues occurs because the I2C SW library loads but isn’t included explicitly so the sketch won’t load (yay c)
Resolution
The fix is documented here and is available for people who clone their Energia from Github instead of using the installation binary.
You have two options:
Clone/Update from the GitHub repo
Make the changes yourself!
Your choice…
Option 1 - Clone/Update
Ensure you have git installed and clone the repo to a desired location on your hard drive
git clone --recursive https://github.com/energia/Energia.git
If you already have a clone of Energia then:
git submodule update --init --recursive
git submodule sync
cd emt
git pull
cd ..
Option 2 - Update yourself
Navigate to the following subdirectory of the Energia folder and open twi_sw.c
Energia\h ardware\m sp430\c ores\m sp430\t wi_sw.c
On line 26 you should see your #include "twi_sw.h"
. Just below that add the following line:
#if DEFAULT_I2C == -1 /* indicates SW I2C on pseudo module 1 */
On the last line in the file (just after the last bracket) add your endif statement
#endif // #if DEFAULT_I2C = -1 /* indicates SW I2C on pseudo module 1 */
Results
After making the changes above you should be able to push your sketch over to your MSP430 without any issues