Hello, My project uses SPI2 to connect three slave devices, use LPSPI_PCS0, LPSPI_PCS1, LPSPI_PCS2, how to send and receive data to each slave device.
...
LPSPI_DRV_MasterInit(SPI2_0, &masterState, &lpspiCom3_MasterConfig0);
LPSPI_DRV_MasterInit(SPI2_1, &masterState, &lpspiCom3_MasterConfig1);
LPSPI_DRV_MasterInit(SPI2_2, &masterState, &lpspiCom3_MasterConfig2);
while(1)
{
delay(1000);
LPSPI_DRV_MasterTransferBlocking(SPI2_0, &masterDataSend, &masterDataReceive, BUFFER_SIZE, TIMEOUT);
LPSPI_DRV_MasterTransferBlocking(SPI2_1, &masterDataSend, &masterDataReceive, BUFFER_SIZE, TIMEOUT);
LPSPI_DRV_MasterTransferBlocking(SPI2_2, &masterDataSend, &masterDataReceive, BUFFER_SIZE, TIMEOUT);
}
Is that right? SPI2_0, SPI2_1,SPI2_2 value is how much?
Please help me.
Thank you.
Best Regards.
Hi,
I am unable to get the LPSPI0 communication sending and receiving problem. here is the below code and PINsettings
The problem is solved, the use of any one slave device, you must re-initialize the configuration data, and then you can send and receive data. thank you all.
Best Regards.
Look at my configuration map
const lpspi_master_config_t lpspiCom3_MasterConfig0 = {
.bitsPerSec = 500000U,
.whichPcs = LPSPI_PCS0,
.pcsPolarity = LPSPI_ACTIVE_LOW,
.isPcsContinuous = true,
.bitcount = 8U,
.lpspiSrcClk = 8000000U,
.clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,
.clkPolarity = LPSPI_SCK_ACTIVE_LOW,
.lsbFirst = false,
.transferType = LPSPI_USING_INTERRUPTS,
.rxDMAChannel = 255,
.txDMAChannel = 255,
};
const lpspi_master_config_t lpspiCom3_MasterConfig1 = {
.bitsPerSec = 500000U,
.whichPcs = LPSPI_PCS1,
.pcsPolarity = LPSPI_ACTIVE_LOW,
.isPcsContinuous = true,
.bitcount = 8U,
.lpspiSrcClk = 8000000U,
.clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,
.clkPolarity = LPSPI_SCK_ACTIVE_LOW,
.lsbFirst = false,
.transferType = LPSPI_USING_INTERRUPTS,
.rxDMAChannel = 255,
.txDMAChannel = 255,
};
const lpspi_master_config_t lpspiCom3_MasterConfig2 = {
.bitsPerSec = 500000U,
.whichPcs = LPSPI_PCS2,
.pcsPolarity = LPSPI_ACTIVE_LOW,
.isPcsContinuous = true,
.bitcount = 8U,
.lpspiSrcClk = 8000000U,
.clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,
.clkPolarity = LPSPI_SCK_ACTIVE_LOW,
.lsbFirst = false,
.transferType = LPSPI_USING_INTERRUPTS,
.rxDMAChannel = 255,
.txDMAChannel = 255,
};
I was wondering how to initialize and how to call a function to receive and send data to each slave
Thank you.
Best Regards.
Hi,
The first paramter of the LPSPI functions is the instance number.
You want to use only one LPSPI device to control all the slaves or you want to control each slave with one master device?
Best regards,
Razvan