<?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: Using GPIO as Chip Select pin for SPI in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-GPIO-as-Chip-Select-pin-for-SPI/m-p/307304#M13088</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please be attention that GPIO is slow module, which exists delay when register was set or cleared. If customer want to use GPIO pin as SPI chip select, the GPIO pin toggle frequency should be slower than 2 MHz.&lt;/P&gt;&lt;P&gt;The key point your mentioned problem is not GPIO toggle frequency, please check if SPI communication interval time and SPI baud rate. Please add time delay between each&amp;nbsp; SPI communication and check again:&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_X_H)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;STRONG&gt;Please add time delay here&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_X_L)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ma Hui&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>Thu, 08 May 2014 04:14:03 GMT</pubDate>
    <dc:creator>Hui_Ma</dc:creator>
    <dc:date>2014-05-08T04:14:03Z</dc:date>
    <item>
      <title>Using GPIO as Chip Select pin for SPI</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-GPIO-as-Chip-Select-pin-for-SPI/m-p/307303#M13087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I was wondering how efficient is it to use GPIO as Slave Select pin ?. When I wrote a code in which I am using a default Chip select pin and side by side using GPIO pin just to test what the difference is on probing both the pins, I found the following waveforms. The yellow(channel 1) of the oscilloscope shows the inbuilt CS pin. the Blue(channel 2) of the oscilloscope shows the GPIO pin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="cs.JPG.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/43822iBC911E93AAA4E1D0/image-size/large?v=v2&amp;amp;px=999" role="button" title="cs.JPG.jpg" alt="cs.JPG.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here I am sending 6 bytes data so CS pin is going low 6 times in the first case it is going down in fixed interval but in later case CS pin is going to logic 0&amp;nbsp; for 6 times but not at fixed intervals. Below is the simple code which is in my infinite loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; for(;;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_X_H)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_X_L)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_Y_H)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_Y_L)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_Z_H)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_Z_L)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt;The above test I did in FRDMK20D50M board where the SPI_CS is PTD0 and the external CS is PTE0&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt;Actually in 1 of my project I am using KL05 uc in that there is only 1 dedicated CS pin, so in that case for adding multiple slave device I need to use GPIO. SO please help me out in this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt;Amit Kumar&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 09:42:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-GPIO-as-Chip-Select-pin-for-SPI/m-p/307303#M13087</guid>
      <dc:creator>Amit_Kumar1</dc:creator>
      <dc:date>2014-04-30T09:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using GPIO as Chip Select pin for SPI</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-GPIO-as-Chip-Select-pin-for-SPI/m-p/307304#M13088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please be attention that GPIO is slow module, which exists delay when register was set or cleared. If customer want to use GPIO pin as SPI chip select, the GPIO pin toggle frequency should be slower than 2 MHz.&lt;/P&gt;&lt;P&gt;The key point your mentioned problem is not GPIO toggle frequency, please check if SPI communication interval time and SPI baud rate. Please add time delay between each&amp;nbsp; SPI communication and check again:&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_X_H)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;STRONG&gt;Please add time delay here&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; SM1_SendChar((read|ACC_X_L)&amp;lt;&amp;lt;8 |dc); &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="western"&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: Courier New,monospace;"&gt; CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ma Hui&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>Thu, 08 May 2014 04:14:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-GPIO-as-Chip-Select-pin-for-SPI/m-p/307304#M13088</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2014-05-08T04:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using GPIO as Chip Select pin for SPI</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-GPIO-as-Chip-Select-pin-for-SPI/m-p/307305#M13089</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 think what is happening here is that there is no wait after the send function before toggling the GPIO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you add a delay, or check for TCF flag on K-Series, after this function and before the GPIO toggle it should help you. What can happen after you call the send function is that the core will exit the function and move on to the next one before the SPI module has shifted the whole byte out.Therefore, the GPIO will not be toggling at the same rate that the bytes are leaving the SPI module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13995731207085917" jivemacro_uid="_13995731207085917" modifiedtitle="true"&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New', monospace;"&gt;CS_ClrVal(csp);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New', monospace;"&gt;SM1_SendChar((read|ACC_X_H)&amp;lt;&amp;lt;8 |dc);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New', monospace;"&gt;//Insert delay or check for transmit complete here
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New', monospace;"&gt;CS_SetVal(csp);&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martyn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 18:14:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-GPIO-as-Chip-Select-pin-for-SPI/m-p/307305#M13089</guid>
      <dc:creator>martynhunt</dc:creator>
      <dc:date>2014-05-08T18:14:20Z</dc:date>
    </item>
  </channel>
</rss>

