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.
I am using MSP430F538 with bq40z50 as a slave device. As per the data sheet SLAU208N–June 2008–Revised May 2014 the single byte transmission to be handled as
"When transmitting a single byte of data, the UCTXSTP bit must be set while the byte is being transmitted or
anytime after transmission begins, without writing new data into UCBxTXBUF. Otherwise, only the
address is transmitted"
but as per my previous discussion from
https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/347546
they said single byte transmission is possible by using interrupt. Since i have developed the interrupt code for transmission as follows
// Vector 12: TXIFG case 12: if (nbytestoBeTxfr > 0) { // Transfer next byte UCB0TXBUF = *data; nbytestoBeTxfr--; data++; } else { // UCTXSTP - Generate Stop condition UCB0CTL1 |= UCTXSTP; // Transfer completed // Disable Transmit Interrupt UCB0IE &= ~UCTXIE; } break;
If i see the output logic analyzer my slave device address only always send, and the SCL is keep on continuing even after stop bit generation, i never seen the data which to be send. Can anyone knows is the above way of handling is correct? I have seen some of the sample codes for i2c interrupt implementation, in that also they are developing the same way, but i am ending up with this issue. Could any one help me to solve this issue.
Also initial time the NACKIFG flag is set even the device is connected. After that it is not occurring and during that time i am facing the above said issue.
Thanks in advance
Prakash,
I really need to see more of your code to know for sure. Can you post that along with the MSP you're using? MSP430F538 appears to be a typo.
What is the value of nbytestoBeTxfr? If it's more than 1, then you will assign a new value before issuing a STOP condition.
You could either set this to 1, OR you can Set UCASTPx to 10 (automatic stop generation), and set the byte counter UCBxTBCNT to 1.
Both of these values should only be modified when UCSWRST = 1.
"When the data is transferred from the buffer to the shift register, UCTXIFG0 is set, indicating data transmission has begun, and the UCTXSTP bit may be set. When UCASTPx = 10 is set, the byte counter is used for STOP generation and the user does not need to set the UCTXSTP. This is recommended when transmitting only one byte."
It looks like you may need to reset the counter for each transmission:
"When operating in master mode with automatic STOP generation (UCASTPx = 10), the UCTXIFG0 is set as many times as defined in UCBxTBCNT."
Let me know if this helps or if you have any questions.
Best regards,
Cameron
**Attention** This is a public forum