Hi. I have been made SPI slave activation but I have a problem.
I hope somebody helps me
Master : S32K144 (64pin)
Slave : S32K144 (64pin)
Problem :
- In case Master's PCS polarity and Slave's PCS polarity are 'Active low', Slave does not transfer.
- Only in case both PCS polarity are 'Active high', Slave transfers correctly
[Configuration]
- Master : PCS polarity is Active low
- Slave : PCS polarity is Active low
[Picture]
- PCS polarity is Active low(yellow) and Slave does not transfer(pink)
- PCB polarity is Active high(yellow) and Slave trasfers(pink)
[Source code]
void PORTB_ISR(void) // PCS is input to PTB0 and PORTB generates interrupt for falling edge
{
LPSPI_DRV_SlaveTransfer(RECEIVE,&slaveDataSend,slaveDataReceive,BUFFER_SIZE);
}
int main(void){
...
INT_SYS_EnableIRQ(PORTB_IRQn);
INT_SYS_InstallHandler(PORTB_IRQn, &PORTB_ISR, NULL);
LPSPI_DRV_SlaveInit(RECEIVE,&ReceiveState,&Receive_SlaveConfig0);
...
}
Hi,
Can you attache your project on this thread?
Best regards,
Razvan
Hi.
I'm sorry for late response.
Thank you for your attention.
I resolved above problem using digital input interrupt.
By the way, am I right?
Thank you.
Kim.
Hi Kim,
I'm not 100% sure that your approach is recommended because CS is managed by lpspi hardware.
When you want to use SPI in slave mode you can't avoid that interrupt. You can take a look at the LPSPI example.
The main idea is to configure the slave transfer before the moment when the master will request data.
Other hint is that you can use the end transfer callback to prepare the next transfer. (It is available on EAR 0.8.4)
For example:
int main(void){
...
INT_SYS_EnableIRQ(PORTB_IRQn);
INT_SYS_InstallHandler(PORTB_IRQn, &PORTB_ISR, NULL);
LPSPI_DRV_SlaveInit(RECEIVE,&ReceiveState,&Receive_SlaveConfig0);
LPSPI_DRV_SlaveTransfer......
/* Now the master can request the data from slave.
...
}