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.
Hi all,
I'm using UCB0 I2C in MSP430F2618.
I need to use Repeated Start Condition to read the Data from the slave. the sequence is as follows.
I'm using LTC2942 as slave.
I'm able to get the code worked for half of the transaction of the above. the MSP is not changing into Receiver mode soon after the Transmitter mode.
I worked around some issues that are posted in http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/p/225082/798727.aspx#798727 .
The code I used is as follows.
#include "msp430f2618.h"
unsigned int d;
void main(void) {
WDTCTL = WDTPW + WDTHOLD;
P3SEL |= 0x06; // 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 = 10; // fSCL = SMCLK/10 = >100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x64;
UCB0CTL1 &= ~UCSWRST;
while (1)
{
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
UCB0TXBUF = 0x01;
UCB0CTL1 &= ~UCTR;
UCB0CTL1 |= UCTXSTT;
d = UCB0RXBUF;
UCB0CTL1 = UCTXSTP;
}
}
the Slave is putting the data on to the BUS. but the MSP is not receiving the data. the variable is not getting updated by the value that was put by the slave. (I'm confirming that the slave is putting data on to the bus by seeing with a Logic Sniffer)
the code worked for some instance. I started writing an API for integrating the Battery Gas Gauge to the MSP. In the middle of the work the Slave stopped responding for the commands. the slave can work for SCLK of 400kHz.
Please help me to get out of this.
Hi tulasi dwarakanath, The problem is with the timing in I2c communication.. after sending the slave address n start condition ur trying to send the register Immediately without even waiting for the ack from slave. Same case after u hv sent the repeated start Also, ur reading it immediately . Try to maintain proper state machine. Like, in a while loop Poll for the status register to c if u received ack ( same thing can be achieved with isrs ) Only on receiving ack/nack proceed with furtherstate. Sent from my android
**Attention** This is a public forum