The spi of MKL16Z128 cann't receive the data,please help!

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

The spi of MKL16Z128 cann't receive the data,please help!

963件の閲覧回数
frankitchen
Contributor I

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?

 

0 件の賞賛
返信
1 返信

942件の閲覧回数
Sabina_Bruce
NXP Employee
NXP Employee

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.

nxf51209_0-1601411948609.png

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!

----------------------------------------------------------------------------------------------------------------------- 

0 件の賞賛
返信