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.

TMS320F28035: SPI Communication from TMS320F28035

Part Number: TMS320F28035
Other Parts Discussed in Thread: DRV8711,

Hi TI community,

I am trying to use TMS320F28035 (master) to communicate with  DRV8711 (slave) via spi. The SPI communication is 16 bits. With CS high, I am able to push data onto the buffer but I am not able to read the data back as my MISO is always high.
There should be no problem with the data format I am sending MSB as 0/1 for write/read, Bit 12-14 as address and the rest is 12 bits of DRV8711 register.
I am receiving the exact same data on my SPIRXBUF. The data is not getting written onto the DRV8711 registers which means my SPI Initialization could be messed up.

Can you review below code based on your experience??


GpioCtrlRegs.GPAPUD.bit.GPIO16 = 0; // Enable pull-up on GPIO16 (SPISIMOA)
GpioCtrlRegs.GPAPUD.bit.GPIO17 = 0; // Enable pull-up on GPIO17 (SPISOMIA)
GpioCtrlRegs.GPAPUD.bit.GPIO18 = 0; // Enable pull-up on GPIO18 (SPICLKA)

GpioCtrlRegs.GPAQSEL2.bit.GPIO16 = 3; // Asynch input GPIO16 (SPISIMOA)
GpioCtrlRegs.GPAQSEL2.bit.GPIO17 = 3; // Asynch input GPIO17 (SPISOMIA)
GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3; // Asynch input GPIO18 (SPICLKA)


GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1; // Configure GPIO16 as SPISIMOA
GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1; // Configure GPIO17 as SPISOMIA
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1; // Configure GPIO18 as SPICLKA

GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO19 = 1;
GpioDataRegs.GPACLEAR.bit.GPIO19 = 1;

I am using GPIO19 as I/O and not SPISTEA as DRV8711 needs to have CS high while read/write. So GPIO19 will be high before sending 16 bits of data and then go low.


====================================================================================
SPI Initialization

SpiaRegs.SPIFFTX.all=0xE040;
SpiaRegs.SPIFFRX.all=0xE040;
SpiaRegs.SPIFFCT.all=0x0000;
SpiaRegs.SPICCR.all =0x00BF;
SpiaRegs.SPICTL.all =0x0006;
SpiaRegs.SPISTS.all=0x0000;
SpiaRegs.SPIBRR =0x007F;
SpiaRegs.SPIPRI.all = 0x0011;

====================================================================================
SPI Write

SPI_Write(Uint16 dataHi)
{
GpioDataRegs.GPASET.bit.GPIO19 = 1;

SpiaRegs.SPITXBUF=dataHi;
while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) { }
readData |= (SpiaRegs.SPIRXBUF);

GpioDataRegs.GPACLEAR.bit.GPIO19 = 1;
}

  • You said MISO stays high--does that mean you've confirmed on an oscilloscope/logic analyzer that MOSI looks correct?

    It looks like you have the SPILBK bit set in the SPICCR. That connects SIMO and SOMI internally, so that could be causing problems for you.

    Whitney
  • I can write to my registers after changing SpiaRegs.SPICTL.all = 0x000F making the Clock phase bit = high so that data is transmitted and received a half cycle before the SPICLK transition.
    I have one more question regarding reading the registers. In my SPI initializations, SPIBLK bit in SPICCR register (used to enable/disable Loop-back) is set to high. I was hoping that by turning it low I would be able to send the address of a register of DRV8711 via write and receive back the data of the register associated with that address but that’s not the case. I am writing 1000000000000000 to DRV8711 to read Control register’s bits instead I am receiving back 1000000000000000. So what should I change in order to receive the data and not get a loopback.
  • You definitely want SPILBK to be set to zero. Are all registers reading back incorrectly or just the control register?

    Like I asked in my previous post, have you been able to check the MISO and MOSI signals using an oscilloscope or a logic analyzer?

    Thanks,

    Whitney

  • I changed SPIBK to zero but still not able to read the register. I am receiving 0 on RXBUF for all registers.
    I used oscilloscope to check MISO and MOSI. I am getting perfect MOSI signal and MISO is always high. I am using 4 wire mode.

    Also, my master transmits only when the polarity is 0 and phase is 1 (Rising edge with delay). How does it not work for other polarity phase combinations? How to decide that in this case.
    SpiaRegs.SPICTL.all =0x000E; //phase = 1, Master/slave=1, Talk=1
    SpiaRegs.SPICCR.all =0x000F; //polarity = 0, SPIBLK=0
    SpiaRegs.SPIPRI.all = 0x0012;
  • I see no reason why changing the polarity and phase would cause the master to fail to send. However, an SPICCR value of 0x000F will not send anything because the SPISWRESET is cleared. Try SPICCR = 0x008F instead?

    Whitney
  • I have cleared SPISWRESET before changing the configurations. After all the configurations setting SPISWRESET to high (SPICCR= 0x008F).
  • I am now able to read DRV 8711 Registers by pulling MISO pin high.
    Thanks for the help!