Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years ago.
KL25Z - Does anyone have a working example of an interrupt driven SPI Slave?
I cannot get the KL25Z to recognize SPI Master messages.
In the following code example I am trying to get the SPI1 module, configured as a Slave, to receive a byte from the SPI Master, and illuminate the tri-color LEDs based on the value of the data sent.
If I strip out the device.Receive() command, I can see that the interrupt service is taking place, so I can only conclude that the SPI message from the Master is never being recognized.
Does anyone have any ideas for figuring this one out?
6 years, 3 months ago.
I tried your code on a Nucleo 152RE which is clocked slower (32Mhz) than the KL25z (48Mhz), you are using and it also did not work. Looking at he code would lead one to expect that it should work....So what is the problem?
Two cups of coffee and a cigar in the garage gave me an idea. Perhaps it is a timing issue with NOT enough elapsed time from SS or chip select being asserted by the master and detected, by the SPI slave board , and an interrupt being generated and data being received. There is some amount of code to be processed after an interrupt before the called isr can run , and how long before the called functions finish and fetch the receive data .
So I tried adding a small delay, wait(0.0001); in the SPI master code between cs =0; and the spi.write statement and the code now works.
Oddly enough the SPI Master is running on a KL25Z
I needed a interrupt driven SPI Slave running in a project using the .Nucleo 152RE and while searching for a solution I discovered your posting from 21 months ago.. What was your solution to the problem you were experiencing?