Hi,I get a problem for the MCU of MKL16Z128,I use SPI to communicat with the device (m95m01).
part of my code is:
void flashInit(void)
{
SIM->SCGC4 |= SIM_SCGC4_SPI1_MASK;
SPI1->C1 = 0x5e;
SPI1->C2 = 0x10;
SPI1->BR = 0x01;
}
void spisend(uint8 byte)
{
while(!(SPI1->S & SPI1_S_SPTEF_MASK))
{;}
SPI1->DL = byte;
}
uint8 spirecv(void)
{
uint8 byte;
while(!(SPI1->S & SPI1_S_SPRF_MASK))
{;}
byte = SPI1->DL;
return byte ;
}
Through logic analyzer,I can get the Correct timing for sending byte to the device, but it can not get the Correct timing to receive the data from device.so why?
Hello Frank,
Hope you are doing well.
I recommend to use the examples in the SDK for the FRDM-KL26 which support MKL16. Here you will find four different examples using spi.
You may use these as a reference to get your application working for the device you are using.
The SDK can be downloaded from MCUXpresso SDK.
Please let me know if you have further questions.
Best Regards,
Sabina
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------