Hi,
I am facing an issue with LPSPI in S32K144 while sending and receiving 8 bytes of data in one call. I am not using driver that is provided with SDK.
In Master I have tried with 8 bits frame and 32 bits frame but I am not able to successfully receive data on slave side. sometimes it successfully returns one call of transmission but then stuck on the second call for ever.
Here are configurations and transmit function for master:
void lpspi_init()
{
LPSPIx_CR = 0x00000000UL;
LPSPIx_IER = 0x00000000UL;
LPSPIx_CFGR0 = 0x00000000UL;
LPSPIx_CFGR1 = 0x00000001UL;
LPSPIx_CCR = 0x00000000UL;
LPSPIx_TCR = 0x4080001FUL;
LPSPIx_FCR = 0x00000003UL;
LPSPIx_CR = 0x00000009UL;
}
bool lpspi_sendData(uint8 * pData)
{
bool retval = false;
while(0 == (LPSPIx_SR & (uint32)0x01));
LPSPIx_TDR = (uint32)(pData[3]<<24|pData[2]<<16|pData[1]<<8|pData[0]);
LPSPIx_TDR = (uint32)(pData[7]<<24|pData[6]<<16|pData[5]<<8|pData[4]);
LPSPIx_SR |= LPSPI_SR_TDF_MASK;
retval = true;
return retval;
}
Configurations and Receive function for slave:
void lpspi_init()
{
LPSPIx_CR = 0x00000000UL;
LPSPIx_IER = 0x00000000UL;
LPSPIx_DER = 0x00000003UL;
LPSPIx_CFGR0 = 0x00000000UL;
LPSPIx_CFGR1 = 0x00000000UL;
LPSPIx_CCR = 0x00000000UL;
LPSPIx_TCR = 0x40800007UL;
LPSPIx_FCR = 0x00020000UL;
LPSPIx_CR = 0x00000001UL;
}
void ll_rx rx_buff_struct* rx_buffer)
{
if((LPSPIx_SR & LPSPI_SR_RDF_MASK)>>LPSPI_SR_RDF_SHIFT)
{
rx_buffer->frame.data[0] = LPSPIx_RDR;
rx_buffer->frame.data[1] = LPSPIx_RDR;
rx_buffer->frame.data[2] = LPSPIx_RDR;
rx_buffer->frame.data[3] = LPSPIx_RDR;
rx_buffer->frame.data[4] = LPSPIx_RDR;
rx_buffer->frame.data[5] = LPSPIx_RDR;
rx_buffer->frame.data[6] = LPSPIx_RDR;
rx_buffer->frame.data[7] = LPSPIx_RDR;
LPSPIx_SR = (((uint32)(((uint32)(0))<<LPSPI_SR_RDF_SHIFT))&LPSPI_SR_RDF_MASK);
rx_buffer->received = true;
rx_buffer->frame.atyp = Physical;
}
else
{
rx_buffer->received = false;
}
}
Master just stuck at "while(0 == (LPSPIx_SR & (uint32)0x01));" and doesn't move forward. But if I am debugging and step over it it will then move forward. In normal run it just stuck here.
Here I am not receiving anything in Master and there is no transmission in Slave.
Can you please check and see what is it that I am not doing right. Your quick response to this issue will be highly appreciated.
razva_tilimpea