I am trying to configure the MCP23017 I/O expander with the MSP430G2553 mcu. The I/O expander uses I2C
and when I try and send data to the device, the mcu only calls the tx interrupt once which never triggers a stop
condition that is in the ISR for I2C transmit. Please let me know what I am doing wrong.
int main(void) { Grace_init(); // Activate Grace-generated configuration UCB0I2CSA = 0x40; // Configure the Load device TxData[0] = 0x00; // Write to the IODIRA Register TxData[1] = 0x00; // Set all pins in port A as outputs TxData[2] = 0x01; // Write to the IODIRB Register TxData[3] = 0x00; // Set all pins in port B as outputs TxData[4] = 0x0C; // Write to the GPPUA Register TxData[5] = 0xFF; // Enable pull-up resistors on all pins in port A TxData[6] = 0x0D; // Write to the GPPUB Register TxData[7] = 0xFF; // Enable pull-up resistors on all pins in port B PTxData = (unsigned char *)TxData; TXByteCtr = sizeof TxData; UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition } #pragma vector=USCIAB0TX_VECTOR __interrupt void USCI0TX_ISR_HOOK(void) { if(TXByteCtr) // Check TX Byte byte counter { UCB0TXBUF = *PTxData++; // Load TX Buffer TXByteCtr--; // Decrement TX byte counter } else { UCB0CTL1 |= UCTXSTP; // I2C stop condition IFG2 &= ~UCTXSTP; // Clear USCI_B0 TX int flag __bic_SR_register_on_exit(LPM0_bits); // Exit LPM if all data was transmitted } }