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.

TMS470 SPI Loopback

Other Parts Discussed in Thread: HALCOGEN

Hi, I'm new to TI chips so sorry for silly questions.

When I send data via TG0 I get the same data on the same TG0. I suppose the SPI loopback is enabled. How can I change LoopBack using Halcogen?

  • I do not see a option in Halcogen for setting up the loopback mode. Would you please check SPI global control register 1 and IO loopback test register to see if loopback is enabled?

    Thanks and regards,

    Zhaohong
  • Hi Zhaohong and thank you for your response.

    Global control register 1 is 0x01000003

    IO loopback test control register is 0x00000000

    I have checked values after initialization.

    Seems that loopback is disabled but I'm receiving the same data like loopback is ON

  • I would suggest checking if the TX and RX pins are shorted.

    Thanks and regards,

    Zhaohong
  • They are not shorted, I'm sure.

    I'm trying to communicate with SD card using tms470MF066. tms470MF066  is Master. SPI signals are generated fine from MOSI and SD card successfully responds. The blue is MOSI and yellow is MISO

      Nevertheless, when I debug I get in my rxBuffer the same data I have sent via txBuffer.

    Would you be kind to have a look at my simple code please. I'm run out of ideas what could be wrong. Drivers generated using Halcogen

    2084.SPI.rar

  • Would you please add SPI CS and SPI CLK to this waveform? On SPI, transmission and reception happen simultaneously. With those two additional signals, we will be able to see what is going on.

    Thanks and regards,

    Zhaohong
  • Actually I have only 2 channel oscilloscope, but knowing that the same signals are sent repeatedly I was able to edit the following image to show MISO(upper yellow), CLK (yellow in the middle), MOSI (blue)

    In green region I'm sending 0x40 0x00 0x00 0x00 0x00 0x95 to SD card

    in red region array of 10 0xFF 's was sent in order to receive response from SD card. (card responds as expected)

    CS is always asserted (using GPIO)

    Any clues?

  • I would like to propose another experiment to check if the SPI module sees pins correctly.

    (1) Configure MOSI as a GIO output and MISO as a GIO input.
    (2) Leave both pins open. Change the state of the MOSI and check if MISO state changes in the SPI pin state register. MISO state should not change when it is open.
    (3) Connect those two pins together. Now MISO state should follow MOSI.

    We can debug SPI communication after the pin function/connection is confirmed.

    Thanks and regards,

    Zhaohong
  • Done.
    1. Configured MOSI as a GIO output and MISO as a GIO input
    2. While changing MOSI level, the MISO doesn't change
    3. When connected MISO follows MOSI
    All as you expected.
    p.s. I think there are typos in TRM (www.ti.com.cn/.../spnu495c.pdf) from page 496 (SPI Pin Control Register 0-8).
  • With the MOSI and MISO pins open, run your SPI test. Use the scope to monitor the two pins. You should able to see the data on the MOSI pin. MISO should stay constant high or low. The value in the SPIBUF register should be either 0x0 or 0xffff depending on the state of the MISO pin. On SPI, SPIDAT0 and SPIDAT1 are transmit registers. SPIBUF is the receive register.

    Thanks and regards,

    Zhaohong
  • Thank for your help, Zhaohong.

    Eventually, I had to write my own function to read coming data from RXBUF as spiGetData() function does not read the register. Now I have so many doubts about correctness of Halcogen generated codes.