<?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 Help with SPI - MC9S08GT32 in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189147#M14442</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Hi everyone,&lt;BR /&gt;Well, i`m&amp;nbsp; working with SPI in a proyect with MC9S08GT32 cpu&lt;BR /&gt;The problem i have is that i can`t find the facts that debugger gives me&amp;nbsp; to be consistent with explanation of the datasheet.&lt;BR /&gt;First,&amp;nbsp; after&amp;nbsp; after writing the data register the one&amp;nbsp; which sends data to the transmit register,&amp;nbsp; the debugger always show me the value of the data register to be null.&lt;BR /&gt;Second, the secuence i see when I simule&amp;nbsp; the next piece of code is,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sending secuence&lt;BR /&gt;&amp;nbsp;while ( 1 ){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( ! SPI1TF) ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI1D =0xFF;&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;&amp;nbsp; /* writes the transmit buffer register of spi */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;the transmit empty flag is set in 0 value after writing two consecutive bytes, and i think it should be set 0 value after 1 writing . Another problem is when the flag is finally set&amp;nbsp; to 0, it never comes back to 1 value (ready to trasmit another byte)&lt;BR /&gt;&lt;BR /&gt;I really think that the secuence to send a byte is, seeing if the transmit empty&amp;nbsp; flag is set, then write the data register, and the is suposed that the thata is send after 8 spi clock times. and then repeat the cycle.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;well the only&lt;/SPAN&gt;&lt;SPAN&gt;thing i can see is that the SPI is not working, if someone can help me, send me a piece of code that&amp;nbsp; has used succsesfuly, please i need some help&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Added p/n to subject.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by NLFSJ on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-09-29&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:09 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Sep 2008 11:58:49 GMT</pubDate>
    <dc:creator>juanb_arg</dc:creator>
    <dc:date>2008-09-28T11:58:49Z</dc:date>
    <item>
      <title>Help with SPI - MC9S08GT32</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189147#M14442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Hi everyone,&lt;BR /&gt;Well, i`m&amp;nbsp; working with SPI in a proyect with MC9S08GT32 cpu&lt;BR /&gt;The problem i have is that i can`t find the facts that debugger gives me&amp;nbsp; to be consistent with explanation of the datasheet.&lt;BR /&gt;First,&amp;nbsp; after&amp;nbsp; after writing the data register the one&amp;nbsp; which sends data to the transmit register,&amp;nbsp; the debugger always show me the value of the data register to be null.&lt;BR /&gt;Second, the secuence i see when I simule&amp;nbsp; the next piece of code is,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sending secuence&lt;BR /&gt;&amp;nbsp;while ( 1 ){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( ! SPI1TF) ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI1D =0xFF;&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;&amp;nbsp; /* writes the transmit buffer register of spi */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;the transmit empty flag is set in 0 value after writing two consecutive bytes, and i think it should be set 0 value after 1 writing . Another problem is when the flag is finally set&amp;nbsp; to 0, it never comes back to 1 value (ready to trasmit another byte)&lt;BR /&gt;&lt;BR /&gt;I really think that the secuence to send a byte is, seeing if the transmit empty&amp;nbsp; flag is set, then write the data register, and the is suposed that the thata is send after 8 spi clock times. and then repeat the cycle.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;well the only&lt;/SPAN&gt;&lt;SPAN&gt;thing i can see is that the SPI is not working, if someone can help me, send me a piece of code that&amp;nbsp; has used succsesfuly, please i need some help&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Added p/n to subject.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by NLFSJ on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-09-29&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:09 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Sep 2008 11:58:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189147#M14442</guid>
      <dc:creator>juanb_arg</dc:creator>
      <dc:date>2008-09-28T11:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189148#M14443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello and welcome to the fora, Juan.&lt;BR /&gt;&lt;BR /&gt;You can not read the SPI tx buffer. Attempting this gives you the receive buffer, RTFM.&lt;BR /&gt;See this &lt;A href="http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;message.id=6713" target="_blank"&gt;thread&lt;/A&gt; for how to do it.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Sep 2008 12:09:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189148#M14443</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2008-09-28T12:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189149#M14444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For C programs,&amp;nbsp;the typical&amp;nbsp;function&amp;nbsp;for the master to transfer&amp;nbsp;a single byte in each direction would be -&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;byte SPI_trans( byte val)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;{&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; while (!SPI1S_SPTEF);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; SPI1D = val;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Send byte value&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; while (!SPI1S_SPRF);&amp;nbsp; // Wait for completion of transfer&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; return SPI1D;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Arial"&gt;&lt;FONT face="Arial"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The final read of SPI1D is necessary under all circumstances, to clear the SPRF flag and prevent an overrun&amp;nbsp;condition.&amp;nbsp; The&amp;nbsp;manipulation of the SS output is external to the function.&amp;nbsp; You probably will not be able to single step this code without disrupting its operation.&amp;nbsp; This is because it is possible for the debugger itself to clear the hardware flags before the code can test the flag status.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To send&amp;nbsp;each byte to the SPI slave device (and ignore the returned value), use the following call.&amp;nbsp; The cast avoids a compiler warning because the returned value is not used.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;(void)SPI_trans( byte_value);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To read the returned data from the slave, it is&amp;nbsp;necessary to send a byte, usually a dummy value.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;return_value = SPI_trans( 0);&amp;nbsp; // Dummy send&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-09-28&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;04:30 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Sep 2008 13:20:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189149#M14444</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-09-28T13:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189150#M14445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;Hi again!&lt;BR /&gt;Well i must say that i appreciate a lot your help, it is really useful.&lt;BR /&gt;I`ve done a little piece of code&amp;nbsp; and&amp;nbsp; tested it with full chip simulator, I think it`s going to work.&lt;BR /&gt;now i can see that i didnt understand prpeperly the manual... &amp;nbsp;&lt;BR /&gt;well&amp;nbsp; thanks again!&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Juan Bautista&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Sep 2008 05:25:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-SPI-MC9S08GT32/m-p/189150#M14445</guid>
      <dc:creator>juanb_arg</dc:creator>
      <dc:date>2008-09-29T05:25:44Z</dc:date>
    </item>
  </channel>
</rss>

