SPI in KL25Z with 2 slaves

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI in KL25Z with 2 slaves

1,160 Views
xiaocongfu
NXP Employee
NXP Employee

Hello,

I'm now working with SPI in KL25Z using PE. I want to connecter the SPI with 2 slaves.

For the first chip select, I have chosen PTE/SPI1_PCS0, and with the second, no matter I choose PTB10/SPI_PCS0 or PTD4/LLWU_P14/SPI_PCS0/UART2_RX/TPM0_CH4, I always have an error: "Only one pin resource with CS0 feature can be contained in the Chip select list".

So I'd like to ask how to solve this problem, or if it's possible to connecter 2 slaves at the same time with SPI of KL25Z.

Thanks in advance for your answers!

0 Kudos
8 Replies

852 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Xiaocong,

For the SPI module of KL25 only have one chip select pin , these pin "PTE/SPI1_PCS0""PTB10/SPI_PCS0 or PTD4/LLWU_P14/SPI_PCS0/UART2_RX/TPM0_CH4" are all SPI_PCS0.

So on the PE component , we only can select one spi slave .

And if you want to use two SPI slave, please use another GPIO to link one SPI slave , when you want select this SPI slave , clear the GPIO output "0" .


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

852 Views
xiaocongfu
NXP Employee
NXP Employee

Hello Alice,

Thank you for your answer !

According to what you said, I can assume that for one interface SPI, we can connecte only one slave, right?

And the problem is, another SPI of the KL25Z is used for the communication between OpenSDA and SWD. So can I use it to connecte a slave? If answer is no, how can I link two slaves?

Regards,

Xiaocong

0 Kudos

852 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Xiaocong,

No, the SPI of KL25 can connect two slave.

As i said, we can use other gpio to connect to slave SPI.

In fact, i recommend you use two gpio connect the two SPI slave, thus can simply control it .

For example , configure GPIO_1 connected to SPI_1,  GPIO_2 connected to SPI_2 ,  when you want select the SPI_1 slave , set the GPIO_1 pin to 0.

Hope it helps

Alice

0 Kudos

852 Views
xiaocongfu
NXP Employee
NXP Employee

I don't understand how to "use two gpio connect the two SPI slave" in PE, can you give more details ?

Thank you

0 Kudos

852 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

OK !

Please add the "BitIO" component , then configure the pin you use , for example ,i sue PTE21 connect to spi1 slave, and PTE 0 connect to spi2 slave.

pastedImage_0.png

In the hardware, link the two pin to the "ss" pin of that two SPI slave.

0 Kudos

852 Views
DerekLau
Contributor IV

A GPIO pin, connecting to the SS pin of the slave, can be used to select the slave device.

0 Kudos

852 Views
tsi-chung_liew
NXP Employee
NXP Employee

Xiacong,

You need a different Chip Select for each slave is used. If both slaves used the same CS, it will have bus contention. Assuming you have two SPI flash (slave), you need CS0 for flash0 and CS1 for flash1.

Regards,

TsiChung

0 Kudos

852 Views
xiaocongfu
NXP Employee
NXP Employee

Hello TsiChung,

Thank you for your answer!

As said Alice, in PE for one SPI interface, the chip select pins are all PCS0. I dont have another choice.

Regards,

Xiaocong

0 Kudos