AnsweredAssumed Answered

SPI and FRDM-K64F - strange behavior

Question asked by Francesco Rugiano on Dec 14, 2014

Hi all

I have a little problem with my FRDM-K64F board. I'm trying to communicate with an SPI peripheral (touchscreen contoller), but it behaves in a strange way.

I connected it to the SPI0 pins, then all I have to do is to send him the configuration byte and he gives me the data. Since it needs 24 clock cycles to give me the results, I send it the configuration byte and two dummy bytes.


So I have to send him three bytes. The function I made to do this job is attached (I can't find any "code" block here).


So... If I call this function this way:


byte recvbuff[3] = { 0, 0, 0};

byte sendbuff[3] = { 0x90, 0, 0 };

SpiManager_SendAndReceive(sendbuff, 3, recvbuff, 3);

(i.e. with both buffers 3 bytes wide) I get this on the SPI wires:


So the bytes are spaced by a 1us time delay. This is good and is exactly what I wanted.

BUT if I call it this way:

byte recvbuff[3] = { 0, 0, 0};

byte sendbyte = 0x90;

SpiManager_SendAndReceive(&sendbyte, 1, recvbuff, 3);

(i.e. just one byte in the send buffer buffer) what I get is this:


The bytes are separated by a 20us delay. This is not good, since the other device doesn't like it (and gives me strange data).

What is the problem?

I also attached the SPI_LDD confguration.

Thank yuo for your help

Original Attachment has been moved to: