AnsweredAssumed Answered

SPI Slave - number of received bytes

Question asked by Peter Frnka on Nov 18, 2018
Latest reply on Nov 27, 2018 by Raymundo Velarde

Hello,

 

I am new in development with Kinetis microcontroller (MK66FN2M0VMD18) and I am trying to create an application which read not specified number of bytes (SPI frame) from SPI Master using an interrupt. I was able to implement basic functionality because I went through the downloaded examples. 

 

void SPI0_DriverIRQHandler(void)
{
   while(DSPI_GetStatusFlags(SPI0) & kDSPI_RxFifoDrainRequestFlag)
   {   
      slaveRxData[counter++] = DSPI_ReadData(SPI0);

      DSPI_ClearStatusFlags(SPI0, kDSPI_RxFifoDrainRequestFlag);
   }
}

 

Slave receives valid SPI frame and stores it to the slaveRxData buffer. Comparing to the examples, interrupt is disabled and receive process is completed when number of received bytes is equal to an expected value, but there is no expected number of bytes in my application.

 

When should I disable interrupt and how can I detect when SPI does not receive any SPI frame ? I would expect that SPI status register SPI0_SR has busy flag.

 

Thanks a lot !    

Outcomes