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.

TMS320F28069: I have a problem that does not work SPI-A Slave between TMS320F28069(Master) to TMS320F28069(Slave).

Part Number: TMS320F28069

I have a problem that did not work SPI-A Slave between TMS320F28069(Master) to TMS320F28069(Slave).

Clock, SPISIMOA, SPICLKA, and /SPISTEA signals of master that measured an oscilloscope worked normally.

Yellow is SPICLKA, and Blue is /SPISTEA.

However, it did not work a SPI-A Rx of Master and Rx/Tx of Slave. (SPI-A Tx worked normally).

(And I wonder that Master and Slave of SPI-B work normally as well.)

 

I connected SPI-A ports as below.

[Master]              [Slave]

GPIO16(SPISIMOA) <-> GPIO16(SPISIMOA)

GPIO17(SPISOMIA) <-> GPIO17(SPISOMIA)

GPIO18(SPICLKA) <-> GPIO18(SPICLKA)

GPIO19(/SPISTEA) <-> GPIO19(/SPISTEA)

 

I connected SPI-B ports as below.

[Master]              [Slave]

GPIO12(SPISIMOB) <-> GPIO16(SPISIMOB)

GPIO25(SPISOMIB) <-> GPIO17(SPISOMIB)

GPIO26(SPICLKB) <-> GPIO18(SPICLKB)

GPIO15(/SPISTEB) <-> GPIO19(/SPISTEB)

 

 

And my test code as below.

 

void spia_init(void)  //--- Master

{

#if 1  //--- SPI-A

       SpiaRegs.SPICCR.all   = 0x000F;

       SpiaRegs.SPICTL.all   = 0x0006;

       SpiaRegs.SPIBRR       = 0x007F;

       SpiaRegs.SPICCR.all   = 0x008F;

SpiaRegs.SPIPRI.bit.FREE= 1;

#else  //--- SPI-B

       SpibRegs.SPICCR.all   = 0x000F;

       SpibRegs.SPICTL.all   = 0x0006;

       SpibRegs.SPIBRR       = 0x007F;

       SpibRegs.SPICCR.all   = 0x008F;

SpibRegs.SPIPRI.bit.FREE = 1;

#endif

}

 

void spib_init(void)  //--- Slave

{

#if 1

       SpiaRegs.SPICCR.all   = 0x000F;

       SpiaRegs.SPICTL.all   = 0x0002;                                                         

       SpiaRegs.SPIBRR       = 0x007F;

 

       SpiaRegs.SPICCR.all   = 0x008F;

       SpiaRegs.SPIPRI.bit.FREE = 1;

#else  //--- SPI-B

       SpibRegs.SPICCR.all   = 0x000F;

       SpibRegs.SPICTL.all   = 0x0002;

       SpibRegs.SPIBRR       = 0x007F;

       SpibRegs.SPICCR.all   = 0x008F;

       SpibRegs.SPIPRI.bit.FREE = 1;

#endif

}

 

void spia_xmit(Uint16 a){

#if 1  //--- SPI-A

       SpiaRegs.SPITXBUF=a;          //--- Master

#else  //--- SPI-B

       SpibRegs.SPITXBUF=a;          //--- Master

#endif

}

void spib_xmit(Uint16 a){

#if 0

       SpiaRegs.SPITXBUF=a;          //--- Slave

#else

       SpibRegs.SPITXBUF=a;          //--- Slave

#endif

}

 

 

void spia_fifo_init() //--- Master

{

#if 1  //--- SPI-A

       // Initialize SPI FIFO registers

       SpiaRegs.SPIFFTX.all  = 0xE040;

SpiaRegs.SPIFFRX.all  = 0x2040;

       SpiaRegs.SPIFFCT.all  = 0x0;

       SpiaRegs.SPIFFTX.bit.SPIFFENA = 1;   //--- 2017.01.24 추가

 

#else  //--- SPI-B

       // Initialize SPI FIFO registers

       SpibRegs.SPIFFTX.all=0xE040;

       SpibRegs.SPIFFRX.all=0x2040;

       SpibRegs.SPIFFCT.all=0x0;

#endif

}

 

void spib_fifo_init() //--- Slave

{

#if 1  //--- 2017.01.23 SPI-A <-> SPI-A Slave TEST (YONG)

       // Initialize SPI FIFO registers

       SpiaRegs.SPIFFTX.all=0xE040;

       SpiaRegs.SPIFFRX.all=0x2040;

       SpiaRegs.SPIFFCT.all=0x0;

       SpiaRegs.SPIFFTX.bit.SPIFFENA = 0;

#else  //--- SPI-B

       // Initialize SPI FIFO registers

       SpibRegs.SPIFFTX.all=0xE040;

       SpibRegs.SPIFFRX.all=0x2044;

       SpibRegs.SPIFFCT.all=0x0;

 

       SpibRegs.SPIFFTX.bit.SPIRST = 1;

       SpibRegs.SPIFFTX.bit.SPIFFENA = 0;

       SpibRegs.SPIFFTX.bit.TXFFINTCLR = 1;

       SpibRegs.SPIFFTX.bit.TXFIFO = 1;

 

       SpibRegs.SPIFFRX.bit.RXFFIL = 0;

#endif

}

 

void SPI_TEST_4th(void) {

       Uint32 sdata; // send data

       Uint32 rdata; // received data

       Uint32 dummy;

       sdata = 0x0000;

 

       while(1){

#if MASTER     //--- Master

               // Transmit data

               SpiaRegs.SPITXBUF=sdata;

 

               // Wait until data is received

               while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) { }

               // Check against sent data

               rdata = SpiaRegs.SPIRXBUF;

               rdata++;

               rdata = 0;

 

               sdata++;

               #endif

#else  //--- Slave

               // wait data from master

               while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) {}   // Waits until data rx’d

               rdata = SpiaRegs.SPIRXBUF;                   // Slave reads data

               // send data to master

               SpiaRegs.SPITXBUF = rdata;                   // Slave transmits data

               while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) {}   // Wait until data rx’d

               dummy = SpiaRegs.SPIRXBUF;

               dummy++;

               dummy = 0;

 

               sdata++;

#endif

       }

}

 

void DSP_Port_Init(void){

       //--- SPI COMMUNICATION Init. Start -------------------

       InitSpiGpio();

#if MASTER

       spia_fifo_init();

       spia_init();          // init SPI-A Master

#else

       spib_fifo_init();

       spib_init();          // init SPI-B        Slave

#endif

       //--- SPI COMMUNICATION Init. End ---------------------

}

 

void main(void) {

       InitSysCtrl();

 

       InitGpio();    //

 

       DINT;

 

       InitPieCtrl();

 

       IER = 0x0000;

       IFR = 0x0000;

 

       InitPieVectTable();

       DSP_Port_Init();

 

       // Enable global Interrupts and higher priority real-time debug events:

       EINT;   // Enable Global interrupt INTM

       ERTM;   // Enable Global realtime interrupt DBGM

 

 

       SPI_TEST_4th();

}

 

 

I cannot solve this problem. Please anyone help me.

  • Michael,

    Can you be a little bit more specific on how it is not working? Can you monitor the Slave side and tell if the data is being received? I do not recommend using the SPI_INT flag on the receiver if you are using the FIFO, this may cause your code to hang, and SPI_INT will be cleared when the FIFO grabs the data from the RXBUF. Please use the SPIFFRX.RXFFSTS bits to determine when the data has been received.

    what debug steps have you gone through? can you share what you have done, and your results.

    -Mark