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.

SPI loopback problem

Other Parts Discussed in Thread: TMS320F28035

Hi, I'm having problems with SPI loobpack. The data transmitted by SPI are received correctly by SPI receiver. The interrupt for both receive and transmit are triggered correctly. However, the pin output was incorrect as I only saw one blip of SPI clock signal. Following is my code (TMS320F28035)

 

void enableSPIb() {

SpibRegs.SPICCR.bit.SPISWRESET = 0; // reset SPI

SpibRegs.SPICCR.all = 0x001F; // 16bit loopback, change to 0x000F on final

SpibRegs.SPICTL.all = 0x0017;

SpibRegs.SPISTS.all = 0x0000;

SpibRegs.SPIBRR = 0x000F;//233;

SpibRegs.SPIFFTX.all = 0xC022;

SpibRegs.SPIFFRX.all = 0x0022;

SpibRegs.SPIFFCT.all = 0x00;

SpibRegs.SPIPRI.all = 0x0010;

 

SpibRegs.SPICCR.bit.SPISWRESET = 1; // enable SPI

SpibRegs.SPIFFTX.bit.TXFIFO = 1;

SpibRegs.SPIFFRX.bit.RXFIFORESET = 1;

}

 

interrupt void spibTxFifoIsr() {

int i = 0;

int messageLength = 8;

int16 pdx;

while (SpibRegs.SPIFFTX.bit.TXFFST != 0) {}

for (i = 0; i < 2 && SPICounter < messageLength; i++) {

pdx = SPIChars[SPICounter++];

SpibRegs.SPITXBUF = pdx;

}

 

SpibRegs.SPIFFTX.bit.TXFFINTCLR = 1;

PieCtrlRegs.PIEACK.all |= 0x20;

}

 

interrupt void spibRxFifoIsr() {

int i;

//for (i = 0; i < 2; i++) {

receivedFromSPI0 = SpibRegs.SPIRXBUF;

receivedFromSPI1 = SpibRegs.SPIRXBUF;

//}

SpibRegs.SPIFFRX.bit.RXFFOVFCLR = 1;

SpibRegs.SPIFFRX.bit.RXFFINTCLR = 1;

PieCtrlRegs.PIEACK.all |= 0x20;

}

 

 

And this is the GPIO initialization:

 

//  GPIO-12 - PIN FUNCTION = --Spare--

GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 3; // 0=GPIO,  1=TZ1,  2=SCITX-A,  3=SPISIMO-B

GpioCtrlRegs.GPADIR.bit.GPIO12 = 1; // 1=OUTput,  0=INput 

// GpioDataRegs.GPACLEAR.bit.GPIO12 = 1; // uncomment if --> Set Low initially

GpioDataRegs.GPASET.bit.GPIO12 = 1; // uncomment if --> Set High initially

GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0;

GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 3;

//--------------------------------------------------------------------------------------

//  GPIO-13 - PIN FUNCTION = --Spare--

GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 3; // 0=GPIO,  1=TZ2,  2=Resv,  3=SPISOMI-B

GpioCtrlRegs.GPADIR.bit.GPIO13 = 0; // 1=OUTput,  0=INput 

// GpioDataRegs.GPACLEAR.bit.GPIO13 = 1; // uncomment if --> Set Low initially

GpioDataRegs.GPASET.bit.GPIO13 = 1; // uncomment if --> Set High initially

GpioCtrlRegs.GPAPUD.bit.GPIO13 = 0;

GpioCtrlRegs.GPAQSEL1.bit.GPIO13 = 3;

//--------------------------------------------------------------------------------------

//  GPIO-14 - PIN FUNCTION = --Spare--

GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 3; // 0=GPIO,  1=TZ3,  2=LINTX-A,  3=SPICLK-B

GpioCtrlRegs.GPADIR.bit.GPIO14 = 1; // 1=OUTput,  0=INput 

// GpioDataRegs.GPACLEAR.bit.GPIO14 = 1; // uncomment if --> Set Low initially

GpioDataRegs.GPASET.bit.GPIO14 = 1; // uncomment if --> Set High initially

GpioCtrlRegs.GPAPUD.bit.GPIO14 = 0;

GpioCtrlRegs.GPAQSEL1.bit.GPIO14 = 3;

//--------------------------------------------------------------------------------------

//  GPIO-15 - PIN FUNCTION = --Spare--

GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 3; // 0=GPIO,  1=TZ1,  2=LINRX-A,  3=SPISTE-B

GpioCtrlRegs.GPADIR.bit.GPIO15 = 1; // 1=OUTput,  0=INput 

// GpioDataRegs.GPACLEAR.bit.GPIO15 = 1; // uncomment if --> Set Low initially

GpioDataRegs.GPASET.bit.GPIO15 = 1; // uncomment if --> Set High initially

GpioCtrlRegs.GPAPUD.bit.GPIO15 = 0;

GpioCtrlRegs.GPAQSEL1.bit.GPIO15 = 3;

 

 

Any idea on how to fix this?

Thanks