AnsweredAssumed Answered

MKE02Z Master RX SPI issue

Question asked by Neil Porven on Oct 13, 2016
Latest reply on Oct 14, 2016 by Kerry Zhou

Hi everyone,

 

I am having a bit of an issue with the SPI RX(reading data).  I have the following code:

 

1.    while (!(SPI1_S & SPI_S_SPTEF_MASK))
        {}

 

2.    SPI1_D = 0xFF; //Generate clocks, this shift data in

 

3.    //Wait until SPRF clears
      while ((SPI1_S & SPI_S_SPRF_MASK))
      {}

 

4.   ucData_Read = SPI1_D; //Get the data

 

surprising enough, if I step through it, I get the data I need.  If I let it run, then my data is 0xFF, which is what I initialize

ucData_Read with.  This is what I understood from the manual section of the SPI.  If the SPTEF is set, then the transmit buffer is empty and the D register is ready to receive data, this is what I am doing with step 1.  In step 2, I generate clocks

to shift data in (I can see the clocks and data in my oscilloscope). If the SPRF is set data is waiting to be read, this is what 

I am doing in step 3.  Finally in step 4, I read the data.

 

Can someone tell me if I am missing something?

 

Thanks.

Outcomes