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.

CCS/TMS320F28035: In SPI 3-Wire Mode ,the data has ben shifted through SPIDAT but SPI INT_FLAG bit(SPISTS.6) never set to 1

Part Number: TMS320F28035

Tool/software: Code Composer Studio

Hi All,

I'm drive the TLE5012B(SSC communication) use TMS320F28035 in SPI 3-Wire Mode.In the oscilloscope,I saw the right data has been shifted through SPIDAT ,but INT_FLAG never set 1.

So it always died in "while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) {} // Waits until data rx’d" when I debug it. And this moment RXFFST changed to 1,it indicate Receive

FIFO has 1 word.so indicate data has been shifted through SPIDAT. In the TMS320x2803x SPI datasheet P13:

When the specified number of data bits has been shifted through SPIDAT, the following events occur:
• SPIDAT contents are transferred to SPIRXBUF.
• SPI INT FLAG bit (SPISTS.6) is set to 1.

Here is the code:

void TLE5012B_Configuration(void)

{

SpiaRegs.SPIPRI.bit.TRIWIRE =1;//3-wire Mode

SpiaRegs.SPICCR.bit.SPICHAR = 0x0F; // 16-bit char bits
SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
SpiaRegs.SPICTL.bit.CLK_PHASE = 0;
SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;
SpiaRegs.SPICTL.bit.TALK = 1; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.

SpiaRegs.SPIBRR = 15; // 15 -> 1Mbps
SpiaRegs.SPICCR.bit.SPISWRESET = 1; // Relinquish SPI from Reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission

// Initialize SPI FIFO registers
SpiaRegs.SPIFFTX.all=0xE040;
SpiaRegs.SPIFFRX.all=0x2044;
SpiaRegs.SPIFFCT.all=0x0;
}

Uint16 TLE5012B_Read_Angle(void)
{
Uint16 sdata, rdata;

sdata = 0x8021; // See Demo

SpiaRegs.SPICTL.bit.TALK = 1; // Enable Transmit path
SpiaRegs.SPITXBUF = sdata; // Master transmits data
while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) {} // Waits until data rx’d
dummy = SpiaRegs.SPIRXBUF; // Clears junk data from itself
// bc it rx’d same data tx’d

SpiaRegs.SPICTL.bit.TALK = 0; // Disable Transmit path
SpiaRegs.SPITXBUF = sdata; // Send dummy to start tx
// NOTE: because TALK = 0, data does not tx onto SPISIMOA pin
while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) {} // Wait until data received
rdata = SpiaRegs.SPIRXBUF; // Master reads data

SpiaRegs.SPICTL.bit.TALK = 0; // Disable Transmit path
SpiaRegs.SPITXBUF = sdata; // Send dummy to start tx
// NOTE: because TALK = 0, data does not tx onto SPISIMOA pin
while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) {} // Wait until data received
SW = SpiaRegs.SPIRXBUF; // Master reads data

return rdata-32768;
}

Any help would be greatly appreciated. Thank you in advance! 

  • Hi there.

    Please use the SPIFFTXINT/SPIFFRXINT flags when the FIFO is enabled. The INT_FLAG bit is only applicable when not using FIFO mode.

    Regards,
    Mark