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.

TMS320F28374S: 关于SPI的Master和Slave间通信

Part Number: TMS320F28374S


Master使用的是F28379D的LunchPad,Slave使用的是F28374S芯片的产品板

Master和Slaver使用的都是对应芯片的 spi_ex3_external_loopback_fifo_interrupts Sample。

对Master和Slave的Sample进行修改,修改如下,

Master:

1、不使用送信中断,使用了定时器,在定时器中送信,即,

//
// FIFO and interrupt configuration
//
#if 0
SPI_enableFIFO(SPIB_BASE);
SPI_clearInterruptStatus(SPIB_BASE, SPI_INT_TXFF);
SPI_setFIFOInterruptLevel(SPIB_BASE, SPI_FIFO_TX2, SPI_FIFO_RX2);
SPI_enableInterrupt(SPIB_BASE, SPI_INT_TXFF);
#else
SPI_disableFIFO(SPIB_BASE);
#endif
//
// Configuration complete. Enable the module.
//
SPI_enableModule(SPIB_BASE);

Slave:

1、将SPIB作为Slave端,Sample中原来是将SPIA作为Slaver端,相关的配置如下,

void initSPIBSlave(void)
{
//
// Must put SPI into reset before configuring it
//
SPI_disableModule(SPIB_BASE);

//
// SPI configuration. Use a 500kHz SPICLK and 16-bit word size.
//
SPI_setConfig(SPIB_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
SPI_MODE_SLAVE, 500000, 16);
SPI_disableLoopback(SPIB_BASE);
SPI_setEmulationMode(SPIB_BASE, SPI_EMULATION_FREE_RUN);

//
// FIFO and interrupt configuration
//
SPI_enableFIFO(SPIB_BASE);
SPI_clearInterruptStatus(SPIB_BASE, SPI_INT_RXFF);
SPI_setFIFOInterruptLevel(SPIB_BASE, SPI_FIFO_TX2, SPI_FIFO_RX2);
SPI_enableInterrupt(SPIB_BASE, SPI_INT_RXFF);

//
// Configuration complete. Enable the module.
//
SPI_enableModule(SPIB_BASE);
}

     修改后,应该为,

Master的SPIB发送数据给Slaver的SPIB,Slave收到数据后在中断中送信息给Master端。

但,目前是Slave在中断函数中没有收到相关的数据。

在逻辑分析仪中,确认Master侧发出了相关的数据。参考图片