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.

how to describe C code for only 1Byte with I2C?

Other Parts Discussed in Thread: MSP430F5635

Dear,

Could you please give me your advice for following my question?

Device: MSP430F5635
Peripheral: UCSI_Bx, I2C mode, I2C Master Receiver Mode

I want to get/communicate just only "1 Byte" from/with target device.

But sometime I get "1 Byte", or sometime I get "2 Byte"...

My questions:

Q1) Could you please let me know the exactly timing of "UCTXSTT: 1 => 0"?

slau208m.pdf says in page 972 "UCTXSTT: UCTXSTT is automatically cleared after START condition and address information is transmitted."

Also slau208m.pdf say in page 962 "As soon as the slave acknowledges the address, the UCTXSTT bit is cleared."

I guess UCTXSTT is changing from 1 to 0 automatically when "ACK" from slave is reached at UCSI_Bx:SCxSDA.
Am I right?

 

Q2) Could you give me the C source code example for "UCTXSTP bit must be set while the byte is being received" in page 962 slau208m.pdf?

 

Best regards,
Okayama

 

  • Receiving only one byte indeed is tricky. To do so, you must set UCTXSTP after UCTXSTT has cleared, but before the 8th bit of the first byte has been received.

    Indeed, UCTXSTT gets clear as soon as the ACK cycle is complete (note that in master transmitter mode, the ACK cycle will not complete until something was written to TXBUF or UCTXSTP was set).
    Once this happened, but before the reception of the first byte was done, UCTXSTP needs to be set. If you set it too early, transmission will stop right after the start byte and nothing is received, if you wait too long, reception of a second byte has already started.
    Soy you should have interrupts disabled while waiting for UCTXSTT to clear, then immediately set UCTXSTP and then you can re-enable interrupts.

**Attention** This is a public forum