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.

MSP430FR5969: I2C Configuration

Part Number: MSP430FR5969


Hi,

I am trying to configure I2C for P1.6 & P1.7

i want to send a command 0xFD followed by address 0x44 to write to the slave device.

I do have two devices and checked with the example program 

P1SEL1 |= 0xC0; /* GPIO pin configuration for P1.7 & P1.6 */
/* I2C initialization */

UCB0CTLW0 = 0x0FD1; /* 7 BIT ADDRESS FOR MASTER & SLAVE, master mode I2C,smclk set, slave ack, transmitter, automatic start & stop */
UCB0BRW = 0x001F; /* CLOCK PRESCALAR VALUE SET AS 32 */
UCB0CTLW1 |= UCASTP_2; // Automatic stop generated
UCB0TBCNT = 0x0005; // number of bytes to be received

UCB0CTLW0 = 0x0FD0; /* SOFTWARE RESET DISABLED */
UCB0I2CSA = 0x0044;

/* DATA transmission configuration */

while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 |= UCTXSTT;

while(!(UCB0IFG & UCTXIFG0)){}
UCB0CTL1 ^= UCTXSTT;
UCB0TXBUF = 0xFD;
__delay_cycles(800);
UCB0CTL1 |= UCTXSTP;
// UCB0CTL1 ^= UCTXSTT;
UCB0TXBUF = 0xFD;
// __delay_cycles(1000);
UCB0CTL1 |= UCTXSTP;

  • You don't really say what your problem is;

    This line: "UCB0CTL1 ^= UCTXSTT;" is just asking for trouble. The STT bit clears automatically once the address is sent. In the best case this does nothing. In the worst case it executes after the bit has cleared resulting in a repeated start.

    You select automatic stop generation (with a high count) but then set the stop bit. Either use the auto stop or don't.

    From the scope traces it appears that the address and your data (0xfd) are sent. Then it waits (delay_cycles) till you request a stop condition. A stop halts the transaction and you have to start over again for more data. I suggest you look at the code examples provided by TI.

  • Hi David,

    This is my updated code, my issue is after transmitting the stop command, I2c communication keeps on transmitting. 

    P1SEL1 |= 0xC0; /* GPIO pin configuration for P1.7 & P1.6 */
    /* I2C initialization */

    UCB0CTLW0 = 0x0FD1; /* 7 BIT ADDRESS FOR MASTER & SLAVE, master mode I2C,smclk set, slave ack, transmitter, automatic start & stop */
    UCB0BRW = 0x001F; /* CLOCK PRESCALAR VALUE SET AS 32 */
    UCB0CTLW1 |= UCSWACK; // Automatic stop generated
    UCB0TBCNT = 0x0005; // number of bytes to be received

    UCB0CTLW0 = 0x0FD0; /* SOFTWARE RESET DISABLED */
    /* UCB0CTLW1 NOT UTILIZED, ACK IS DONE BY USCI MODULE */
    UCB0I2CSA = 0x0044;

    while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
    UCB0CTL1 |= UCTXSTT;

    while(!(UCB0IFG & UCTXIFG0)){}
    UCB0TXBUF = 0xFD;
    __delay_cycles(400);//800
    UCB0CTL1 |= UCTXSTP;
    UCB0TXBUF = 0xFA;

    only by sending the extra data to the TX buffer, I am able to get the desired output 

  • Hi 

    What do you do after I2C transmit? After you send STOP signal this I2C will stop, it should not need another byte to stop function.

**Attention** This is a public forum