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;
}