Here i am able to transmit data via LPSPI1 if i have one chip select. But, the problem arises when i try to configure multiple chip select pins one after the other.
I have attached sample code where i have configured multiple chip selects in LPSPI1
Module: LPSPI1
PCS pins: PTA6, PTD3, PTB17
SCLK pin: PTB14
MOSI pin: PTB16
MISO pin: PTB15
I have tried the following methods.
1. Change the PCS selection SFR in LPSPI initialisation function,
i.e. LPSPI1->TCR = 0x5100000F;
2. Configure PCS pins as GPIO and pull one pin LOW at a time and others HIGH.
please refer attached code and do the needful changes in it to make multiple slaves work.
Hi,
Please try something like this:
SELECT_U2();
TRANSMIT_SPI_CMDS();
while((LPSPI1->SR & LPSPI_SR_TCF_MASK)>>LPSPI_SR_TCF_SHIFT==0);
LPSPI1->SR |= LPSPI_SR_TCF_MASK;
LPSPI1_receive_16bits();
SELECT_U3();
TRANSMIT_SPI_CMDS();
while((LPSPI1->SR & LPSPI_SR_TCF_MASK)>>LPSPI_SR_TCF_SHIFT==0);
LPSPI1->SR |= LPSPI_SR_TCF_MASK;
LPSPI1_receive_16bits();
SELECT_U7();
TRANSMIT_SPI_CMDS();
while((LPSPI1->SR & LPSPI_SR_TCF_MASK)>>LPSPI_SR_TCF_SHIFT==0);
LPSPI1->SR |= LPSPI_SR_TCF_MASK;
Otherwise the code that toggles the GPIO doesn't wait for the SPI to complete the transfer.
Regards,
Daniel
Thanks... :smileyhappy: