SPI Slave

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SPI Slave

3,031 次查看
kimjunghyun
Contributor III

Hi. I have been made SPI slave activation but I have a problem.

I hope somebody helps me

Master : S32K144 (64pin)

Slave : S32K144 (64pin)

3.jpg

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

1.jpg

- Slave : PCS polarity is Active low

2.jpg

[Picture]

- PCS polarity is Active low(yellow) and Slave does not transfer(pink)

SPI구현_CS가 L일때 Slave(분홍)가 회신안함.bmp

- PCB polarity is Active high(yellow) and Slave trasfers(pink)

SPI구현_CS가 H일때만 Slave(분홍)가 회신함_CS가 L일때 Slave 회신하도록 수정 필요.bmp

[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);

...

}

0 项奖励
回复
3 回复数

2,185 次查看
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Can you attache your project on this thread?

Best regards,

Razvan

0 项奖励
回复

2,185 次查看
kimjunghyun
Contributor III

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?

14.jpg

Thank you.

Kim.

0 项奖励
回复

2,185 次查看
razva_tilimpea
NXP Employee
NXP Employee

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.

...

}

0 项奖励
回复