<?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>Kinetis MicrocontrollersのトピックRe: Sending data on SPI using Kl25z</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-data-on-SPI-using-Kl25z/m-p/620238#M37080</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/martynhunt"&gt;martynhunt&lt;/A&gt;‌ Could you please answer the above question&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 26 Mar 2017 03:55:03 GMT</pubDate>
    <dc:creator>subhradeepdutta</dc:creator>
    <dc:date>2017-03-26T03:55:03Z</dc:date>
    <item>
      <title>Sending data on SPI using Kl25z</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-data-on-SPI-using-Kl25z/m-p/620237#M37079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The data sheet for KL25z says that to clear the SPTEF bit on the SPI0_S register&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;SPTEF is cleared by reading the S register with SPTEF set and then writing a data value&lt;BR /&gt;to the transmit buffer at D. The S register must be read with SPTEF set to 1 before writing data to the D&lt;BR /&gt;register; otherwise, the D write is ignored&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So does that mean that to send data over SPI I would need to wait for SPTEF to be set to 1 then write to to the data register or is another read of the status register required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example is the below definition sufficient&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;void SPI_write_byte(uint8_t data)&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;while (!(SPI0_S &amp;amp; SPI_S_SPTEF_MASK));&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SPI0_D = data;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;}&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P&gt;or do I need to do something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;void SPI_write_byte(uint8_t data)&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;while (!(SPI0_S &amp;amp; SPI_S_SPTEF_MASK));&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SPI0_D = data;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;while (!(SPI0_S &amp;amp; SPI_S_SPRF_MASK));&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;data = SPI0_D;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also if I want to use SS pin as a manually controlled pin for slave selection and I have MODFEN = 0 and SSOE = 0, then do I just pull the Port C Pin 4 (alternate function 2) low before starting a data transfer and assert it high once the transfer is complete?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Mar 2017 06:05:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-data-on-SPI-using-Kl25z/m-p/620237#M37079</guid>
      <dc:creator>subhradeepdutta</dc:creator>
      <dc:date>2017-03-25T06:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sending data on SPI using Kl25z</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-data-on-SPI-using-Kl25z/m-p/620238#M37080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/martynhunt"&gt;martynhunt&lt;/A&gt;‌ Could you please answer the above question&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Mar 2017 03:55:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-data-on-SPI-using-Kl25z/m-p/620238#M37080</guid>
      <dc:creator>subhradeepdutta</dc:creator>
      <dc:date>2017-03-26T03:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sending data on SPI using Kl25z</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-data-on-SPI-using-Kl25z/m-p/620239#M37081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Subhradeep Dutta,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. SPI byte write and read, you can use this code:&lt;/P&gt;&lt;P&gt;uint8_t SPI_WriteReadData(uint8_t *pRead,uint8_t *pWrite,uint32_t uiLength)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;uint16_t i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for( i=0;i&amp;lt;uiLength;i++)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!(SPI0_S &amp;amp; SPI_S_SPTEF_MASK ) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;SPI0_D = pWrite[i];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!(SPI0_S &amp;amp; SPI_S_SPRF_MASK ) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pRead[i] = SPI0_D;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This is the polling mode, I have attached the code which wrote by myself for your reference.&lt;/P&gt;&lt;P&gt;2. SS pin as a manually controlled pin&lt;/P&gt;&lt;P&gt;&amp;nbsp; As you know, if the SS is automatically controlled by the SPI module, the SS will go to high after each byte sending.&lt;/P&gt;&lt;P&gt;&amp;nbsp; If you want to manually control, it is very easy, you just need to configure the SS pin as the GPIO, then when you want to send the data, pull low, after sending the data, pull high.&lt;/P&gt;&lt;P&gt;&amp;nbsp; GPIO mux is ALT1, you can configure it in the PORTx_PCRn[MUX], then configure the GPIO, use GPIO to control it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&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>Mon, 27 Mar 2017 05:21:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sending-data-on-SPI-using-Kl25z/m-p/620239#M37081</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-03-27T05:21:04Z</dc:date>
    </item>
  </channel>
</rss>

