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.

MSP430F5326: I2C master mode: R/W to R when transmitting address

Part Number: MSP430F5326

Hello,

MSP430F5326 acting as a master, I need to have the r/w bit set to Read while transmitting the address as showed herebelow:

But I only succeeded to have r/w bit at 0.

Here is the code:

    UCB0CTL1 |= UCSWRST;                      /* software reset enabled */
    UCB0CTL0 |= UCMST | UCMODE_3 | UCSYNC ;       /* slave & master adress : 7 bits, single master config, master mode, I2C enabled, synchronous mode */
    UCB0CTL1 = UCSSEL_2 | UCSWRST ;                    /* source slock : SMCLK, USCI logic held during reset state */
    UCB0BR0 = 80; // SPICLK = SMCLK/80  : 100kHz (max 400kHz)
    UCB0BR1 = 0x000;
    UCB0CTL1 &= ~UCSWRST;                      /* clear software reset */

    UCB0I2CSA = slave_adr ;                      // load slave adress
    UCB0CTLW0 |= (UCTR | UCTXSTT);                     // I2C Tx  + start condition
    UCB0IFG &= ~(UCNACKIFG);
    while ((UCB0IFG & UCTXIFG) != UCTXIFG)    /// attente buffer libre
    {
        if ((UCB0IFG & UCNACKIFG) == UCNACKIFG)
        {
            nack = True;
            debug_str("NACK\r\n");
            break;
        }
    }

What am I wrong?

Is there any specific configuration?

Best regards

Mich

  • > UCB0CTLW0 |= (UCTR | UCTXSTT);                     // I2C Tx  + start condition

    Setting UCTR=1 requests Master Transmitter mode, for which the R/W bit is set to 0.

    If you set UCTR=0 ("UCB0CTLW0 &= ~UCTR;") that requests Master Receiver mode, for which the R/W bit is set to 1.  You will not see a TXIFG in Master Receiver mode.

**Attention** This is a public forum