SPI Problem in KL25z and PE on KDS

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

SPI Problem in KL25z and PE on KDS

729 Views
avnergidron
Contributor III

Hi to all,

I am working on the kl25z  with the KDS and  PE acording to Erich Styger great tutorial:  SPI | MCU on Eclipse  .  I have a temperature  sensor I am connecting  throw SPI (with  32-bit wide),  which only have  a MISO. in  addition  I connect to a EEPROM using the same SPI (SPI0), which have both MISO and MOSI, and I use other pins for CS.

I have created the SPI_Master_LDD  component in PE for the communication with both of the SPI devices working without the SPI interrupt mode.

My problem: I try to read the data from the temperature  sensor using only  the SM1_ReceiveBlock without calling the SM1_SendBlock  but that is not working. when I try adding the SM1_SendBlock with a dummy data, it does 8-bit reading and then  8-bit writing and goes around 4 times (because the data size is 32-bit). the problem is because the temperature  sensor is not allowing writing it is sending part of the bits during the clock cycle used for the dummy writing, and what I get is not the complete data  (this is verified using a scope).

am I doing something wrong? Is there a way to make the reading work without calling SM1_SendBlock?

Thanks in advance

Avner

1 Reply

372 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

The similar problem has been discussed on the thread SPIMaster_LDD usage

The SPI device must send and receive data concurrently and the SPI master device must send data to receive any data (see the block diagram and functionality description of the SPI in a reference manual). It also means that the ReceiveBlock() method just prepare a buffer to receive data (it does not initiate the receive transfer) and you must use the SendBlock() method to initiate the data transfer (one byte is sent and received concurrently). When you don't use the MOSI pin (the internal signal is not routed on a pin) the data are not physically transmitted but it does not affect functionality of the SPI device (i.e. the clock is generated and data are received only by the SPI master device).

Therefore you must use the sequence of ReceiveBlock() and SendBlock() to receive any data when you are using SPI_Mastel_LDD component.

Best Regards,

Marek Neuzil