FRDM-K64F SPI Slave not working

13 May 2018

Hello all,

I am using the UBlox C027 and the FRDM K64F for SPI Communication,

K64F Master -> UBlox C027 Slave works great.

UBlox C027 -> K64F Slave won't work.

By not working I mean that all the data i get from the K64F is 0xFF and not the actual data.

If someone could replicate using the K64F as a slave with another board that could be great as I don't have another board

UBlox C027 Master:

int main()
{
    SPI spi(P1_24, P1_23, P1_20, P1_21);

    spi.frequency(100000);
    spi.format(8,0);

    std::vector<int> dataBlock = {1,2,3,4,5,6,7};

    for (int i = 0; i < dataBlock.size(); i++)
    {
        spi.write( dataBlock[i] );
    }
}

K64F Slave:

#include "mbed.h"
#include <vector>

 int main()
 {
     SPISlave device(PTD2, PTD3, PTD1, PTD0);
     device.frequency(100000);
     device.format(8,0);

     std::vector<int> dataBlock;

     while ( !device.receive() );

     while ( device.receive() )
     {
             dataBlock.push_back( device.read() );
     }

     pc.printf("Got data!: ");

     for (int i = 0; i < dataBlock.size(); i++)
     {
         pc.printf("%d ", dataBlock[i]);
     }
     pc.printf("\n"); // Output is "Got data!: 255 255 255 255 255 255"
}

Thanks for any help.