9 years, 10 months ago.

KL25Z, SPI and no MISO

I am trying to drive a string of LED lights that use an SPI interface.The string has a data in port (that I connect to MOSI on the KL25Z) and a clock input (that I connect to the clk output of the KL25). The string has no data output line so I have left the MISO pin of the KL25Z open. THe problem is that the controller hangs as it appears that it is expecting a handshake from the slave device. I have used the SPI port successfully with an SD card. From what I can see on the scope, the MOSI pin sends out a string of data and then stops and waits. And then nothing else happens.

In an attempt to fix this issue, I have declared the MISO pin as NC to try to mark the pin as unused, but that did not work.

Any ideas?

1 Answer

9 years, 10 months ago.

There is no hardware handshake on SPI. The problem is probably in your software. Perhaps it expects a return value on MISO that is not received. Can you show your code. To check the SPI just test with a simple while(1) loop that keeps sending a byte.

while() {
 spi.write(0xAA)
}

I'm only using the spi.write function, so I do not expect anything in return.

I define the SPI with: SPI spi(PTE1,PTE3,PTE2); mosi, miso, sclk

initialize it with spi.format(8,0); spi.frequency(2000000);

and then use the following to write to it: while (n) spi.write(0x00);

posted by Marc Herniter 20 Nov 2014

please use <<code>> and <</code>> around your posted code (each on its own line) to show it properly formatted.

Try a slower clockspeed (100000) first. Note that when you write 0x00 you dont see any data since all bits are 0 and the MOSI line does not float to 1 when idle. The only thing you would see is the toggling SCLK line. What is the 'n' value in the while? is that the return of the spi.write? That could be false since it is the MISO data which is a dummy in this case.

posted by Wim Huiskamp 20 Nov 2014

I figured out the problem. The issue was a memory problem elsewhere. The SPI port now works as expected. Thanks for your help.

posted by Marc Herniter 21 Nov 2014