AnsweredAssumed Answered

ksdk spi slave erroneous data - out of sync

Question asked by mjg8t on Jan 20, 2016
Latest reply on Jan 26, 2016 by Alice_Yang

I am having issues with received slave spi data on the k22f using KSDK 1.3 and processor expert.  I have simplified the project using 2 frdm-k22f boards one as master and one as slave.  The master send 8 bytes of data 1-8 and I check on the slave to see that it received it.

 

The recieve data is not correct and sometime is will miss a byte being sent.  It misses 0d05 consistently.  When 5 is missed the rx does not know that the frame has finished and recieves the first part of the next frame.  It seems to be a timing issue, but I checked the phase,polarties and even slowed the master clock to a snails pace of 130Khz.

 

I have looked at the data on the scope and the tx data is fine.  See attachment to see the 0d05 value being sent (but no received on the slave).

 

I looked at the slave registers and the only thing that looks funny is that the SR.TFUF.  Though the sdk api sends a successful return.

 

I have simplified the project to 8 bytes from 16 where the more bytes are missed and things get worse.

 

Any ideas what is wrong?

 

 

 

#define SPI_BLOCKING 1 #define SPIS_BUF_SIZE 8   //volatile uint8_t spisTxBuf[SPIS_BUF_SIZE] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; //tx on MISO volatile uint8_t spisTxBuf[SPIS_BUF_SIZE] = { 0, 1, 2, 3, 4, 5, 6, 7 }; //tx on MISO volatile uint8_t spisRxBuf[SPIS_BUF_SIZE] = { 0 }; //received from MOSI dspi_status_t result;

 

#ifdef SPI_BLOCKING   result = DSPI_DRV_SlaveTransferBlocking(SPI1_IDX, // number of SPI peripheral   spisTxBuf, // pointer to transmit buffer, can be NULL   spisRxBuf, // pointer to receive buffer, can be NULL   SPIS_BUF_SIZE, // size of receive and receive data   1000); // Time out after 1000ms   if (result != kStatus_DSPI_Success) {   __asm("NOP");   } #else     //non-blocking   result = DSPI_DRV_SlaveTransfer(SPI1_IDX,// number of SPI peripheral   spisTxBuf,// pointer to transmit buffer, can be NULL   spisRxBuf,// pointer to receive buffer, can be NULL   SPIS_BUF_SIZE// size of receive and receive data   );     // Wait for transfer completion   while(kStatus_DSPI_Success != DSPI_DRV_SlaveGetTransferStatus(SPI1_IDX, NULL)); #endif     __asm("NOP"); //breakpoint to inpect data   clearRxArray();     }      

 

ksdk 1.3

kds 3

Original Attachment has been moved to: DEBUG_K22F_SPI_SLAVE.zip

Original Attachment has been moved to: DEBUG_K22F_SPI_MASTER.zip

Outcomes