<?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 Re: K64 Spi master receive two byte zero from slave in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628212#M37741</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So we both see the same issue, ( we need to push additional two bytes)&lt;/P&gt;&lt;P&gt;And &amp;nbsp;according to my understanding it should&amp;nbsp;not happen when the fifo are matched.&lt;/P&gt;&lt;P&gt;data should go back and forth without pushing it.&lt;/P&gt;&lt;P&gt;Eli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Dec 2016 11:32:02 GMT</pubDate>
    <dc:creator>eliar</dc:creator>
    <dc:date>2016-12-27T11:32:02Z</dc:date>
    <item>
      <title>K64 Spi master receive two byte zero from slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628208#M37737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I started with K64 DSPI example, any one ( blocking ,interrupt) which is working for start.&lt;/P&gt;&lt;P&gt;This example does not fit to my requirement where the master should only send data and the slave should answer according to that data.&lt;/P&gt;&lt;P&gt;So i modified the example and the fsl_dspi.c to meet my requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem i am facing is that when the master send data to the slave&amp;nbsp;&lt;/P&gt;&lt;P&gt;it is received correct in the interrupt of the slave( Note - After disable the fifo for both RX and TX and for master and slave because the fifo of SPI 0 is 4 and the fifo for SPI1 is 1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when the slave send data back to the master in the same clock , the first two bytes are 0 and i need to push additional two bytes at the end to get the entire data.&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;If master send 1,2,3,4 &amp;nbsp;the slave gets &amp;nbsp;1,2,3,4&lt;/P&gt;&lt;P&gt;the slave then echo it back &amp;nbsp;1,2,3.4 &amp;nbsp;the master received &amp;nbsp;0 0 , 1 2, &amp;nbsp;&lt;/P&gt;&lt;P&gt;and for the 3,4 &amp;nbsp;i need to send two additional bytes from the master (dummy 0, so total 6 bytes) to get my 1,2,3,4 back&lt;/P&gt;&lt;P&gt;at the master.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Again , i disabled the fifo for SPI0 and 1 because they are not equal .&lt;/P&gt;&lt;P&gt;if i am not disabling the fifo , the slave does not get all the data and it need to be pushed also from the master&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please help me find how to force the slave output the data from the interrupt:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i reduce the code size at the slave interrupt - so here it is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while (DSPI_GetStatusFlags(base) &amp;amp; kDSPI_RxFifoDrainRequestFlag)&lt;BR /&gt; {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dataReceived = base-&amp;gt;POPR;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;DSPI_ClearStatusFlags(base, kDSPI_RxFifoDrainRequestFlag);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;base-&amp;gt;PUSHR_SLAVE = &lt;SPAN&gt;dataReceived &lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;DSPI_ClearStatusFlags(base, kDSPI_TxFifoFillRequestFlag);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;Thanks!,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Dec 2016 10:32:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628208#M37737</guid>
      <dc:creator>eliar</dc:creator>
      <dc:date>2016-12-20T10:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Spi master receive two byte zero from slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628209#M37738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;BR /&gt;I am not sure if you are using the dspi interrupt example in &lt;A href="https://mcuxpresso.nxp.com/en/welcome"&gt;SDK_2.1_MK64FX512xxx12&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="driver_examples dspi interrupt.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/2201i802FDDDF5ECC819D/image-size/large?v=v2&amp;amp;px=999" role="button" title="driver_examples dspi interrupt.png" alt="driver_examples dspi interrupt.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After disable the fifo for both RX and TX and for master and slave(See Line 182 and 254), and modify other two place(See Line 50 and 286).&lt;BR /&gt;That example seems can run correct on my FRDM-K64F board.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="dspi interrupt.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/2087i76673DBCA56933A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="dspi interrupt.png" alt="dspi interrupt.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am a little confused about what you really want.&lt;BR /&gt;Do you want to run the master and slave on one FRDM-K64F board or on two separate FRDM-K64F board?&lt;BR /&gt;Do you want the slave only send back the data which received from the master?(It seems realize the same function with that example.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&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>Thu, 22 Dec 2016 09:21:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628209#M37738</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2016-12-22T09:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Spi master receive two byte zero from slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628210#M37739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your replay.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function&amp;nbsp;DSPI_SetFifoEnable (false, false) does the same as going to Master init and change it, so we both did the same disable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that the DSPI &lt;STRONG&gt;&lt;EM&gt;hide&lt;/EM&gt;&lt;/STRONG&gt; the problem because you think you are getting match but beyond the surface the example do what ever to do in order to get all the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how could it be that if the fifo are &lt;STRONG&gt;not&lt;/STRONG&gt; matched ( 4 and 1) the&amp;nbsp;data is matched?&lt;/P&gt;&lt;P&gt;the upper DSPI code is &amp;nbsp;taking care the data to will arrived ok.&lt;/P&gt;&lt;P&gt;I also did that , i can make it work,&lt;/P&gt;&lt;P&gt;but to make it work , i need to push the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data must be pushed if the fifo are not matched , right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my app , i need to parse the data in the slave , process it and then replay to the master, it is not an echo back up.&lt;/P&gt;&lt;P&gt;so the master send data, the slave push it into a fifo and mean while return 0 back.&lt;/P&gt;&lt;P&gt;when data is processed , the master send back a write as a read back command to allow the slave to push the data back.&lt;/P&gt;&lt;P&gt;this procedure cause the master to get two zeros.&lt;/P&gt;&lt;P&gt;so what i did is that i pushed two more bytes from the master to allow the slave to send all the buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So to reproduce the issue, you can do the following:&lt;/P&gt;&lt;P&gt;1. Transfer data from mater to slave ( when fifo are disabled) - print the data on the slave interrupt&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;you will see that all data arrived ok.&lt;/P&gt;&lt;P&gt;2. in slave interrupt&amp;nbsp;echo it back to the master&lt;/P&gt;&lt;P&gt;3. in master&amp;nbsp;interrupt , print the data you get.&lt;/P&gt;&lt;P&gt;you should see that the first two bytes are zero and to get all the data you need to push additional two bytes from the slave.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Eli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Dec 2016 09:15:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628210#M37739</guid>
      <dc:creator>eliar</dc:creator>
      <dc:date>2016-12-24T09:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Spi master receive two byte zero from slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628211#M37740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eli,&lt;/P&gt;&lt;P&gt;In order to reproduce the issue, I do the following:&lt;BR /&gt;1. Transfer data from mater to slave (when fifo are disabled) - print the data on the slave interrupt see that all data arrived ok.&lt;BR /&gt;2. in slave interrupt echo it back to the master&lt;BR /&gt;3. in master interrupt , print the data you get.&lt;/P&gt;&lt;P&gt;Observe the spi data by oscilloscope: I see that the first byte return is zero.(The slave has not fill the first received&amp;nbsp;data into the fifo.) In order to get all the data I need to push additional one byte from the slave.(See the attached image "master send and receive slave echo.png")&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="master send and receive slave echo.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/3711iFAF604897BAA307C/image-size/large?v=v2&amp;amp;px=999" role="button" title="master send and receive slave echo.png" alt="master send and receive slave echo.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"In my app , i need to parse the data in the slave , process it and then replay to the master, it is not an echo back up."&lt;BR /&gt;The master send a "data ready or not" command and mean while the master get the first zero.&lt;BR /&gt;The slave return "data ready or not" command and mean while the master get the status of&amp;nbsp; slave "data ready or not".&lt;BR /&gt;So in order to get four data after the data of slave has prepared, the master has to pushed two more bytes.(from the master total 6 bytes)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2016 08:58:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628211#M37740</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2016-12-27T08:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Spi master receive two byte zero from slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628212#M37741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So we both see the same issue, ( we need to push additional two bytes)&lt;/P&gt;&lt;P&gt;And &amp;nbsp;according to my understanding it should&amp;nbsp;not happen when the fifo are matched.&lt;/P&gt;&lt;P&gt;data should go back and forth without pushing it.&lt;/P&gt;&lt;P&gt;Eli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2016 11:32:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628212#M37741</guid>
      <dc:creator>eliar</dc:creator>
      <dc:date>2016-12-27T11:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Spi master receive two byte zero from slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628213#M37742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So how can we fix that issue?&lt;/P&gt;&lt;P&gt;How can we tell the SPI to work as 1 to 1 &amp;nbsp;byte transfer&lt;/P&gt;&lt;P&gt;Without the need to push data.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;did not tried with SPI 1 to SPI 2 where the fifo there is in hardware 1( may be there its ok)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is it an hardware bug or a feature that need to eliminate?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Eli&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Dec 2016 13:36:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628213#M37742</guid>
      <dc:creator>eliar</dc:creator>
      <dc:date>2016-12-28T13:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: K64 Spi master receive two byte zero from slave</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628214#M37743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Eli,&lt;BR /&gt;I don't think it's issue.&lt;BR /&gt;You can read the section "Receiving Data" in "&lt;A href="https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi"&gt;Serial Peripheral Interface (SPI)&lt;/A&gt;" first.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SPI Receiving Data.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/3491i3E4291BC0ECCC8FC/image-size/large?v=v2&amp;amp;px=999" role="button" title="SPI Receiving Data.png" alt="SPI Receiving Data.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If the master want to receive the really data and&amp;nbsp; meanwhile send data. The slave should fill the fifo before the master send that first data. But it seem impossible in your app: Since the slave need first recevie the data sent from master, then wait the slave process it and then reply to the master.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"How can we tell the SPI to work as 1 to 1&amp;nbsp; byte transfer"&lt;BR /&gt;You can let the slave fill the fifo before the master send that first data. Then watch the spi waveform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Dec 2016 02:14:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K64-Spi-master-receive-two-byte-zero-from-slave/m-p/628214#M37743</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2016-12-29T02:14:11Z</dc:date>
    </item>
  </channel>
</rss>

