Hello,
I am trying to receive data (as a slave) from another mcu(master) via SPI. I am using SPI_SlaveTransferNonBlocking function call to read the received data. When i print the received data on the console it is always 255. The data i am sending from master is 170(0xAA).
I checked the signal output from MOSI and SCK from master end, the data 0xAA is displayed properly along with clock signal on the DSO.
Important thing is, i did not configure SSEL pin on slave mcu(LPC82x) since we did not have enough pins and also we use only one slave to communicate.
I enabled slave on spi_slave_config_t struct, both clock phase and polarity are same configuration on both sides.
polarity - KSPI_ClockPolarityActiveHigh
phase - KSPI_ClockPhaseFirstEdge
The wiring connection between master and slave is,
Master slave
MOSI ---------> MISO
MISO ---------> MOSI
SCK ---------> SCK
Please help me if you know where i am going wrong.
Hi,
Based on SPI protocol, the /SS pin of spi slave must be asserted when the master transfers data so that the slave can receive the data.
In other words, the spi master must connect the /CS signal or GPIO signal to the /SS pin of slave spi so that the spi slave knows when it receives the data.
In other words, you have to connect the /CS pin of master spi to one of spi0_SSEL0/1/2 pin, which is selected with SWM.
Hope it can help you
BR
XiangJun Rong
Hello,
Thanks for your help !
I configured the spi master mcu gpio to toggle during transmission to slave, (High before start to send & low after finish sending - vice versa).
Master sends 1 byte data to slave every 1 second, slave tries to read at every 500ms(tested to read data at the minimum of 10 ms)
During debugging slave mcu i checked upon the registers, the RXOV & TXUV bits were set. My understanding is sending data continuously at 1 second interval and reading at every 500ms isn't gonna set these bits. Also i am sending a 1 byte data.
Help me where i am going wrong.
TIA
Hi,
This is the spi connection between slave spi of LPC82x and master spi.
Master slave
MOSI ---------> MISO
MISO ---------> MOSI
SCK ---------> SCK
GPIO -------->any port pin for example PIO0_10
You have to use the code to configure the sselx pin.
SWM->PINASSIGN[4]|=0xFF00FFFF;
SWM->PINASSIGN[4]|=0x0A0000;
Then the PIO0_10 will function as slave spi SSEL pin.
2)I do not think it is good method to read the spi data register periodically.
You should use polling mode or interrupt mode to check if there is data in receiver reg, if there is, just read it.
while(1)
{
while(!(SPI->STAT&0x01)) {}
uint32_t temp=SPI->RXDAT;
}
Hope it can help you
BR
XiangJun Rong