How to get at the I2C signals of the MSP432 LaunchPad to the correct pins for the Sensors BoosterPack The TI-RTOS examples for the MSP432 LaunchPad all route the I2C signals to pins that don't match the ones on the Sensors BoosterPack*. Let's fix that.
* also makes the TI-RTOS examples work for the Educational BoosterPack |
What you need:
- MSP432 LaunchPad
- 1 micro-USB cable
- Code Composer Studio
- TI-RTOS for MSP43X
- BOOSTXL-SENSORS
By default, the TI-RTOS examples route the I2C traffic to P1.6 and P1.7. But some BoosterPacks, such as our Sensors kit, expect it on P6.4 and P6.5.
Here are the changes you need to make to your MSP_EXP432P401R.c file to route them correctly for those boards.
Change the universal serial peripheral module to EUSCI_B1 (we also solve a possible SPI conflict with this, see the comments in the I2C section of the source file for more info):
const I2CMSP432_HWAttrs i2cMSP432HWAttrs[MSP_EXP432P401R_I2CCOUNT] = { { .baseAddr = EUSCI_B1_BASE, .intNum = INT_EUSCIB1, .intPriority = (~0), .clockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK } };
And configure the two2 I2C pins:
/* * ======== MSP_EXP432P401R_initI2C ======== */ void MSP_EXP432P401R_initI2C(void) { /* * NOTE: TI-RTOS examples configure EUSCIB0 as either SPI or I2C. Thus, * a conflict occurs when the I2C & SPI drivers are used simultaneously in * an application. Modify the pin mux settings in this file and resolve the * conflict before running your the application. */ /* Select I2C function for I2C_SCL(P6.5) & I2C_SDA(P6.4) */ MAP_GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P6, GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION); MAP_GPIO_setAsPeripheralModuleFunctionOutputPin( GPIO_PORT_P6, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION); /* Initialize the I2C driver */ I2C_init(); }
This results in the following setup:
- J1.9, pin P6.5 is SCL
- J1.10, pin 6.4, is SDA
That's what's needed according to the BoosterPack's doco:
I've tested this with an educational BoosterPack (I don't own a BOOSTXL-SENSORS). The example that I start from is the I2C TMP006 example in the Drivers folder of Resource Explorer.
The BOOSTXL-SENSOR has a newer version of the temperature sensor (TMP007).
[CORTEX_M4_0] Starting the I2C example System provider is set to SysMin. Halt the target to view any SysMin contents in ROV. I2C Initialized! Sample 0: 20 (C) Sample 1: 20 (C) Sample 2: 20 (C) Sample 3: 20 (C) Sample 4: 20 (C) Sample 5: 20 (C) Sample 6: 20 (C) Sample 7: 20 (C) Sample 8: 20 (C) Sample 9: 20 (C) Sample 10: 20 (C) Sample 11: 20 (C) Sample 12: 20 (C) Sample 13: 20 (C) Sample 14: 20 (C) Sample 15: 20 (C) Sample 16: 20 (C) Sample 17: 20 (C) Sample 18: 20 (C) Sample 19: 20 (C) I2C closed!