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 reply right data in SPI slave mode

Hi all,

I use MSP4330F2132 (SPI slave mode) to communicate with Farsens(a type of RFID tag IC, SPI master mode).

The clock signal is 16 (or 24, 32 and more, but can't 8) times continuously .

You know that TX buffer in MSP430 is 8 Bits, so , when clock is coming, the first 8 bits sent  to master is ok.

During this moment,  the Tx shift register is empty so that circuit need time to load new data from Tx buffer.

But, the clock signal is continuous, so that when Tx shift register is ready to send data, the clock signal maybe lose some.

Could you please give me some help about that ? Anyhow I wish all of you have a nice day  :)

  • Hi Songfan,

    It sounds like your situation is this - your master device is going to ask for 2 bytes to be transmitted from the MSP430 slave in a row, and your concern is that the UCxTXBUF is only 1 byte, so how do you load and send the second byte in time?

    The MSP430 actually has two things - the UCxTXBUF transmit buffer, and the transmit shift register. Please see www.ti.com/.../slau144 figure 16-1 and the chapter 16 on the USCI in SPI mode. The UCxTXBUF register is where you write your data, and it is buffered from the actual SPI transmission line. The UCxTXBUF register moves the data into the transmit shift register, which is the register that will actually shift the data out on the SPI SOMI (MISO) line. As soon as the data has been moved from UCxTXBUF into the transmit shift register (before data has necessarily clocked out on the SPI SOMI line), the UCxTXIFG flag will be set to 1 to indicate that the UCxTXBUF register is ready to be loaded with more data.

    This means that you can load your 2nd byte into the UCxTXBUF register as soon UCxTXIFG is set, as soon as the Transmit Shift Register is loaded - you don't have to wait for the data to be sent out on the SPI line. This should give you time to load the 2nd byte while the 1st byte is still being sent back to the master.

    Therefore, you should use your interrupt on UCxTXIFG to let you load the data as soon as possible. Note that you should make sure UCxTXIFG is 1 before loading the next data into UCxTXBUF. Please also note, that your MSP430 main clock frequency needs to be fast enough in relation to the SPI clock frequency, to make sure you have enough time to service the interrupt and load the next value into UCxTXBUF, before the first byte has finished being sent.

    I hope that this helps!
    Regards,
    Katie
  • Hi Katie,

    I'am glad for your reply.
    Thank you! :)

**Attention** This is a public forum