This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430G2553: Can't Control 7-Segment Display Using I2C

Part Number: MSP430G2553
Other Parts Discussed in Thread: MSP430F5529,

Tool/software: Code Composer Studio

I'm using the MSP430 Launchpad in my Microcontroller Applications class. The end goal of my project is to press a button on a keypad and have it output to a 7-segment display using I2C. I have the keypad code working already, but I can't get anything to send over I2C. I started with the msp430g2xx3_uscib0_i2c_08.c example code provided--I assumed it would be plug-and-play (after changing the slave address, of course).

I'm including the body of the example code that I adapted from referencing a working code for the MSP430F5529. The primary problem I'm having currently is that I can't find a vector word for I2C (UCB0IV in this code) for the MSP430G2553. I've combed through a few different datasheets and have been unable to find anything that works. Does anyone have any idea what I can replace that with to get this code working for my 7-segment? Or is this method just not going to work with the MSP430G2553? (Our professor recommended bit-banging, but I'd rather take a cleaner approach if that's possible.)

Thank you!

#include <msp430.h>

unsigned char *PTxData;                     // Pointer to TX data
unsigned char TXByteCtr;
const unsigned char TxData[] =              // Table of data to transmit
{
 0x11,
 0x22,
 0x33,
 0x44,
 0x55
};

int main(void)
{
    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
    P1SEL |= BIT6 + BIT7;                     // Assign I2C pins to USCI_B0
    P1SEL2|= BIT6 + BIT7;                     // Assign I2C pins to USCI_B0
    UCB0CTL1 |= UCSWRST;                      // Enable SW reset
    UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;     // I2C Master, synchronous mode
    UCB0CTL1 = UCSSEL_2 + UCSWRST;            // Use SMCLK, keep SW reset
    UCB0BR0 = 12;                             // fSCL = SMCLK/12 = ~100kHz
    UCB0BR1 = 0;
    UCB0I2CSA = 0x3B;                         // Slave Address is 048h
    UCB0CTL1 &= ~UCSWRST;                     // Clear SW reset, resume operation
    IE2 |= UCB0TXIE;                          // Enable TX interrupt

    while (1)
    {
        PTxData = (unsigned char *)TxData;      // TX array start address
        TXByteCtr = sizeof TxData;              // Load TX byte counter
        while (UCB0CTL1 & UCTXSTP);             // Ensure stop condition got sent
        UCB0CTL1 |= UCTR + UCTXSTT;             // I2C TX, start condition
        __bis_SR_register(CPUOFF + GIE);        // Enter LPM0 w/ interrupts
        // Remain in LPM0 until all data
        // is TX'd
    }
}

//------------------------------------------------------------------------------
// The USCIAB0TX_ISR is structured such that it can be used to transmit any
// number of bytes by pre-loading TXByteCtr with the byte count. Also, TXData
// points to the next byte to transmit.
//------------------------------------------------------------------------------
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0TX_VECTOR))) USCIAB0TX_ISR (void)
#else
#error Compiler not supported!
#endif
{
    int j = 0;
    switch (__even_in_range(UCB0IV, 12))
    {
    case 0:
        break;                           // Vector  0: No interrupts
    case 2:
        break;                           // Vector  2: ALIFG
    case 4:
        break;                           // Vector  4: NACKIFG
    case 6:
        break;                           // Vector  6: STTIFG
    case 8:
        break;                           // Vector  8: STPIFG
    case 10:
        j = 0;
        while (++j < 10)
            ;
        break;                           // Vector 10: RXIFG
    case 12:                                  // Vector 12: TXIFG
        if (TXByteCtr)                            // Check TX byte counter
        {
            UCB0TXBUF = *PTxData++;                 // Load TX buffer
            TXByteCtr--;                            // Decrement TX byte counter
        }
        else
        {
            UCB0CTL1 |= UCTXSTP;                    // I2C stop condition
            IFG2 &= ~UCB0TXIFG;                     // Clear USCI_B0 TX int flag
            __bic_SR_register_on_exit(CPUOFF);      // Exit LPM0
        }
    default:
        break;
    }
}

**Attention** This is a public forum