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.

TMS570LS0914: How to reset (clear) internal Tx buffer in SPI for TMS570 MCU

Part Number: TMS570LS0914
Other Parts Discussed in Thread: HALCOGEN

Hello,
I need reset (clear) internal Tx buffer of SPI1 peripheral in Hercules MCU in slave mode (4 pin - SOMI, SIMO, CLK and CS). If I reinitialize spi through spiInit function (generated by HAL CodeGenerator) it reset (clear) all SPI register except internal Tx buffer. So if I transmit new data (for ex. 0x01, 0x02, 0x03, 0x04)  to SPI, then on SOMI is 2 last bytes from preview data transfer (0x03 and 0x04 - content of  internal Tx buffer) an then my new data (0x01, 0x02). It happens when error/glitches appears on SPI bus and some transfer aren't completed or if slave SPI (TMS570) detect glitches on bus as start of new communication. So it is possible to manually clear content of internal Tx buffer of SPI peripheral for fresh start after error?

Thank you for response.

  • Hello,
    TXBUF, RXBUF and SHIFT REGISTER are user-invisible registers. SPIDAT0 and SPIDAT1 are user-visible, and are physically mapped to the contents of TXBUF

    • If both the TX shift register and TXBUF are empty, then the data is directly copied to the TX shift register. For devices with DMA, if DMA is enabled, a transmit DMA request (TX_DMA_REQ) is generated to cause the next word to be fetched. If transmit interrupts are enabled, a transmitter-empty interrupt is generated.

    • If the TX shift register is already full or is in the process of shifting and if TXBUF is expty then the data written to SPIDAT0 / SPIDAT1 is copied to TXBUF and TXFULL flag is set to 1 at the same time.

    • When a shift operation is complete, data from the TXBUF (if it is full) is copied into TX shift register and the TXFULL flag is cleared to 0 to indicate that next data can be fetched. A transmit DMA request (if enabled) or a transmitter-empty interrupt (if enabled) is generated at the same time.

    In the examples folder under HALCoGen installation you can find "example_spi_Master_Slave.c" where SPI modules is used to transfer and receive data. In HALCoGen Help->Help topics->Examples you can find description how to set MCU for using the example.

  • Hello,

    Did you manage this issue?