<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MKE02Z Master RX SPI issue in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKE02Z-Master-RX-SPI-issue/m-p/633984#M38199</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a bit of an issue with the SPI RX(reading data). &amp;nbsp;I have the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp;while (!(SPI1_S &amp;amp; SPI_S_SPTEF_MASK))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp;SPI1_D = 0xFF; //Generate clocks, this shift data in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp;//Wait until SPRF clears&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; while ((SPI1_S &amp;amp; SPI_S_SPRF_MASK))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. &amp;nbsp; ucData_Read = SPI1_D; //Get the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;surprising enough, if I step through it, I get the data I need. &amp;nbsp;If I let it run, then my data is 0xFF, which is what I initialize&lt;/P&gt;&lt;P&gt;ucData_Read with. &amp;nbsp;This is what I understood from the manual section of the SPI. &amp;nbsp;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. &amp;nbsp;In step 2, I generate clocks&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing in step 3. &amp;nbsp;Finally in step 4, I read the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone tell me if I am missing something?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Oct 2016 04:02:34 GMT</pubDate>
    <dc:creator>neilporven</dc:creator>
    <dc:date>2016-10-14T04:02:34Z</dc:date>
    <item>
      <title>MKE02Z Master RX SPI issue</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKE02Z-Master-RX-SPI-issue/m-p/633984#M38199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a bit of an issue with the SPI RX(reading data). &amp;nbsp;I have the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp;while (!(SPI1_S &amp;amp; SPI_S_SPTEF_MASK))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp;SPI1_D = 0xFF; //Generate clocks, this shift data in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp;//Wait until SPRF clears&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; while ((SPI1_S &amp;amp; SPI_S_SPRF_MASK))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. &amp;nbsp; ucData_Read = SPI1_D; //Get the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;surprising enough, if I step through it, I get the data I need. &amp;nbsp;If I let it run, then my data is 0xFF, which is what I initialize&lt;/P&gt;&lt;P&gt;ucData_Read with. &amp;nbsp;This is what I understood from the manual section of the SPI. &amp;nbsp;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. &amp;nbsp;In step 2, I generate clocks&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing in step 3. &amp;nbsp;Finally in step 4, I read the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone tell me if I am missing something?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2016 04:02:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKE02Z-Master-RX-SPI-issue/m-p/633984#M38199</guid>
      <dc:creator>neilporven</dc:creator>
      <dc:date>2016-10-14T04:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: MKE02Z Master RX SPI issue</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKE02Z-Master-RX-SPI-issue/m-p/633985#M38200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neil,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Please modify your code like this:&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp;while (!(SPI1_S &amp;amp; SPI_S_SPTEF_MASK))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp;SPI1_D = 0xFF; //Generate clocks, this shift data in&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp;//Wait until SPRF clears&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp; while (!(SPI1_S &amp;amp; SPI_S_SPRF_MASK))&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. &amp;nbsp; ucData_Read = SPI1_D; //Get the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You use the wrong code configuration, it should be when the SPI Read Buffer Full Flag=0, it should wait for the received data comming, otherwise, SPIx_S[SPRF]=1 means the data available in the receive data buffer.&lt;/P&gt;&lt;P&gt;Please modify it and test it again.&lt;/P&gt;&lt;P&gt;If you still have question, please let me know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2016 08:36:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKE02Z-Master-RX-SPI-issue/m-p/633985#M38200</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2016-10-14T08:36:39Z</dc:date>
    </item>
  </channel>
</rss>

