Kinetis FRDMK82F and Arduino Communication

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

Kinetis FRDMK82F and Arduino Communication

851 Views
speedyspeedy
Contributor I

Hello NXP community,

 

I am trying to connect a FRDMK82F board (slave) with an Arduino 101 (master) using SPI. The Arduino can send its information to the FRDMK82F reliably without errors (always correct). However, the information sent by the FRDMK82F (received by the Arduino) is always wrong, e.g. 0x97 becomes 0x80.

 

I have tried changing the clock polarity and phase of both the master and the slave to no avail. I used the driver examples from SDK_2.0 FRDM-K82F (particularly "dspi_interrupt_transfer.c") as a reference and the SPI library from Arduino.

 

Can you help me? Is there some kind of compatibility issue with the Arduino boards?

Original Attachment has been moved to: kinetis_spi_arduino.zip

0 Kudos
1 Reply

510 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Speedy Speedy,

       Did you check the SPI communication wave between the K82 and your Arduino?

      Please check the wave, whether the K82 really send out the wrong data?

       Please also check the code, you should make sure your K82 code also send out the data which you want.

     I found in your attached code, you wrote the code like this:

        /*Set slave transfer ready to receive/send data*/
        slaveXfer.txData = slaveTxData;
        slaveXfer.rxData = slaveRxData;
        slaveXfer.dataSize = TRANSFER_SIZE;
        slaveXfer.configFlags = kDSPI_SlaveCtar0;

        DSPI_SlaveTransferNonBlocking(EXAMPLE_DSPI_SLAVE_BASEADDR, &g_s_handle, &slaveXfer);

        if(slaveRxData[0] != 0)
        {
            PRINTF("%u", slaveRxData[0]);
            PRINTF("\r\n");

            delay(8000000);
        }

        slaveTxData[0] = 0x97;
        slaveRxData[0] = 0;

If you want the slave K82 send 0X97, you shold put the

        slaveTxData[0] = 0x97;
        slaveRxData[0] = 0;

Before :

        slaveXfer.txData = slaveTxData;
        slaveXfer.rxData = slaveRxData;
        slaveXfer.dataSize = TRANSFER_SIZE;
        slaveXfer.configFlags = kDSPI_SlaveCtar0;

 

Please modify the code and try again.

If you still can't get the correct data, please also send me your SPI communication wave, with oscilloscope or logic analyzer.

 

Wish it helps you!

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos