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.

MSP430FR2355: Having trouble displaying both i2c bus transactions??

Part Number: MSP430FR2355


Hello...

Here is a "section" of code that doesn't seem to stop on the while(i2cstate......) loop piece.  The code blows right through.....Watching bus transactions the RGB section all data looks good, however on the LCD section I get all zeroes on the data transaction which signals to me the pointer didn't get reset which in turn looks like I never get into the ISR.I2CComplete section...I have tried all kinds of things but to no avail....

The end function is to configure the rgb and lcd prior to entering the infinite while loop.  If I run code I get all the transactions and am sitting at the LPM3_bits + GIE.

    __bis_SR_register(GIE);

    /*
     * initialize RGB
     */
    nonZeroBufDepth = I2C_TxArray_Builder((uint8_t *)InitializeRGB, sizeof(InitializeRGB), RGB_W);
    i2cstate = I2CWRITE;
    sendI2C_data(pI2CStream, nonZeroBufDepth, RGB_12C_ADDRESS);
    
    while(i2cstate != I2CIDLE);

    /*
     * initialize LCD
     */
    nonZeroBufDepth = I2C_TxArray_Builder((uint8_t *)initializeLCD, sizeof(initializeLCD), LCD_multiW);
    i2cstate = I2CWRITE;
    sendI2C_data(pI2CStream, nonZeroBufDepth, LCD_12C_ADDRESS);

    while(1)
    {
        __bis_SR_register(LPM3_bits + GIE);


        if (ISR.I2CComplete)
        {
            /*
             * house-keeping
             */
            ISR.I2CComplete = F;
            i2cstate = I2CIDLE;
            i2c_cnt = 0;
            memset((void *)lcd_rgb_data, 0, sizeof(lcd_rgb_data));
            pI2CStream = lcd_rgb_data;
        }

    }
}


#pragma vector = USCI_B0_VECTOR
__interrupt void I2C_ISR(void)
{
    uint8_t rcv;
    switch(__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG))
    {
      case USCI_NONE: break;
      case USCI_I2C_UCALIFG: break;
      case USCI_I2C_UCNACKIFG: break;
      case USCI_I2C_UCSTTIFG: break;
      case USCI_I2C_UCSTPIFG:
          ISR.I2CComplete = T;
          i2cstate = I2CSTOP;
          LPM3_EXIT;
          break;

  • I'm not quite sure what you're describing -- are you watching with a scope or with the debugger?

    Is i2cstate declared "volatile"? Also, keep in mind that the I2C unit will continue running (for a little while anyway) while you're at a breakpoint; this distorts the timing and makes debugging such code tricky.

  • Hello Bruce....

    I am watching with a logic analyzer and debugger....ic2state is (__vo is volatile): 

    typedef __vo enum {I2CIDLE, I2CWRITE, I2CREAD, I2CRESTART, I2CSTOP, I2CNACK} i2cCause;
    

    Here is a pic showing the TWO transactions even with a breakpoint set : 

    Here is all the code in main in that it may give you a better understanding. The breakpoint is on the memset.  I am doing two writes prior to the forever while loop (code is not complete at the moment as more will go in this loop).  You can see I set the GIE bit prior to the transactions so that they occur....It seems ISR.I2CComplete never gets set back to F.....As I write this I THINK I am seeing part of the answer...I was thinking that after ISR.I2CComplete = T (from within ISR) I would go to the section of code within while (1) and resolve this to F but I guess given the code has run that far yet it will never nor act on this specific section will it???  (the fact that ISR.I2CComplete never = F indicates this to me).    

  • Sorry, I can't understand your question clearly.

    It seems that the LCD configuration is not successful. As you said " however on the LCD section I get all zeroes on the data transaction". However, see from the result of the digital analyzer, it is not 0x00.

    Can you check whether the bytes sent out to LCD is right?

**Attention** This is a public forum