Part Number:MSP432P401R
Tool/software: Code Composer Studio
I am trying to communicate between a Raspberry Pi and an MSP432 Microcontroller over I2C. Raspberry Pi is the Master and MSP432 is the Slave.
I am running a very simple code on both devices but I get an error when the Raspberry Pi tries to communicate with the MSP432.
On running i2cdetect -y 1 from the raspberry pi terminal it is able to detect the MSP432 at address 0x48 which is good.
However when I run a python code to retrieve some data I get the following error:
OSError: [Errno 121] Remote I/O error
On the MSP432 I am running a basic example program from the resource explorer: msp432p401x_euscib0_i2c_10.c
I edited the code to just turn on the LED when the master sends an I2C interrupt. I have attached the code below.
I tried reducing the baud rate of the raspberry pi but it doesn't work. I get the same error.
I am fairly new to programming and embedded systems. Any help would be appreciated.
#include "ti/devices/msp432p4xx/inc/msp.h"
#define TX_DATA_SIZE 5
uint8_t TXData;
uint8_t TXDataSize;
int main(void)
{
WDT_A->CTL = WDT_A_CTL_PW | // Stop watchdog timer
WDT_A_CTL_HOLD;
// Configure GPIO
P1->SEL0 |= BIT6 | BIT7; // I2C pins
P1->DIR |= BIT0; // P1.0 set as output
// Initialize TX data variable
TXData = 0;
TXDataSize = 0;
// Enable global interrupt
__enable_irq();
// Enable eUSCIB0 interrupt in NVIC module
NVIC->ISER[0] = 1 << ((EUSCIB0_IRQn) & 31);
// Configure USCI_B0 for I2C mode
EUSCI_B0->CTLW0 = EUSCI_A_CTLW0_SWRST; // Software reset enabled
EUSCI_B0->CTLW0 = EUSCI_A_CTLW0_SWRST | // Remain eUSCI in reset state
EUSCI_B_CTLW0_MODE_3 | // I2C mode
EUSCI_B_CTLW0_SYNC | // Sync mode
EUSCI_B_CTLW0_SSEL__SMCLK; // SMCLK
EUSCI_B0->I2COA0 = 0x48 | // own address is 0x48 + enable
EUSCI_B_I2COA2_OAEN;
EUSCI_B0->CTLW0 &= ~EUSCI_A_CTLW0_SWRST;// Release eUSCI from reset state
EUSCI_B0->IE |= EUSCI_B_IE_TXIE0 | // Enable transmit interrupt
EUSCI_B_IE_STPIE; // Enable stop interrupt
// Don't wake up on exit from ISR
SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
// Ensures SLEEPONEXIT takes effect immediately
__DSB();
// Enter LPM0
__sleep();
__no_operation();
}
// I2C interrupt service routine
void EUSCIB0_IRQHandler(void)
{
if (EUSCI_B0->IFG & EUSCI_B_IFG_STPIFG)
{
// Clear stop condition int flag
EUSCI_B0->IFG &= ~EUSCI_B_IFG_STPIFG;
// Reset the pointer
TXDataSize = 0;
}
if (EUSCI_B0->IFG & EUSCI_B_IFG_TXIFG0)
{
P1->OUT ^= BIT0; // Blink P1.0 LED
while(1); // Delay
}
}