<?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>8-bit Microcontrollers中的主题 Re: SPI</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-08GB60/m-p/177524#M12535</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I took two DEMO9S08GB60 boards and connected the MOSI/MISO/SS/SPSCLK and gnd wires together and started to play with your code.&lt;/DIV&gt;&lt;DIV&gt;I got the idea that you had mixed some of the signal names together, as I had&amp;nbsp;to rewrite part of it.&lt;/DIV&gt;&lt;DIV&gt;However, I soon could send data from one MCU to another, and it worked just fine.&lt;/DIV&gt;&lt;DIV&gt;Well not all the time. Once the reception went wrong, it stayed wrong.&lt;/DIV&gt;&lt;DIV&gt;So I tried to use the /SS signal to tell the slave when a new byte of data was on its way.&lt;/DIV&gt;&lt;DIV&gt;But it turned out to be difficult in getting the /SS line to wiggle.&lt;/DIV&gt;&lt;DIV&gt;It seems that it wont go high until the line has been idle for at least one character transmission time.&lt;/DIV&gt;&lt;DIV&gt;So I changed that by pulling the I/O lines "by hand".&lt;/DIV&gt;&lt;DIV&gt;It seems to be working now.&lt;/DIV&gt;&lt;DIV&gt;The data transmitted was a string = "ABCD".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In your code you&amp;nbsp;transmitted the received data from the SPI to the SCI.&lt;/DIV&gt;&lt;DIV&gt;As the SPI is generally far more faster than the SCI, that could also be one of the reasons why you got your problems.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am including two photos. The top trace is the MOSI signal. The second is the /SS signal and the third the SPSCLK signal. The first photo shows what happens with the selector AUTOSLAVE set to TRUE.&lt;/DIV&gt;&lt;DIV&gt;In this case the SPI is taking care of the transmission. I had to add a delay between the characters in order to ever see the /SS signal go high.&lt;/DIV&gt;&lt;DIV&gt;On the second picture, I toggle the /SS signal by hand.&lt;/DIV&gt;&lt;DIV&gt;The pulses on the /SS are much shorter now.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To check what was received, you can stop the receiver and check the "error" counter.&lt;/DIV&gt;&lt;DIV&gt;It turned out to be 0 the last times I tried it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The code was written in CodeWarrrior 6.1.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Hope this helps!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Ake&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://www.freescale.com/files/community_files/8BITCOMM/8727_gb60_spi3.zip" rel="nofollow" target="_self"&gt;GB60_SPI3.zip&lt;/A&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by t.dowe on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-10-27&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;12:54 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Jan 2008 21:25:48 GMT</pubDate>
    <dc:creator>Ake</dc:creator>
    <dc:date>2008-01-11T21:25:48Z</dc:date>
    <item>
      <title>SPI - 08GB60</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-08GB60/m-p/177523#M12534</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;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have done one simple program in SPI&amp;nbsp;.&lt;/DIV&gt;&lt;DIV&gt;From master sending one char contniously ,If reciver flag is set then after clearing the flag send the recived value to SCI. In slave , only clearing &amp;nbsp;the SPI reciver flag. Since In SPI when master start transmitting it will also start receving what ever data in the slave shift register at that time. So &amp;nbsp;from the second data of transfer from master. Master is expected to receive whatever data that send to slave previously.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #330066;"&gt;Master Code:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;while(1)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;SPDR = &lt;SPAN style="color: #CC0000;"&gt;name&lt;/SPAN&gt;;&lt;BR /&gt;&amp;nbsp; while(!SPSCR_SPRF);&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rec_data = SPDR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; sendSCIchar(rec_data);&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #330066;"&gt;Slave code:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;while(1)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; while(!SPSCR_SPRF);&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rec_data = SPDR;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When &lt;SPAN style="color: #CC0000;"&gt;name&amp;nbsp;= &amp;nbsp;'A'&lt;/SPAN&gt;&amp;nbsp; Not getting A all the times.&lt;/DIV&gt;&lt;DIV&gt;When &lt;SPAN style="color: #CC0000;"&gt;name = &amp;nbsp;'B'&lt;/SPAN&gt;&amp;nbsp; Getting B contniouly.&lt;/DIV&gt;&lt;DIV&gt;When sending&amp;nbsp; two data in the while loop that is when sending A and B from master.&lt;/DIV&gt;&lt;DIV&gt;Getting AB contniously.&lt;/DIV&gt;&lt;DIV&gt;when &lt;SPAN style="color: #CC0000;"&gt;name = 'C'&lt;/SPAN&gt;&amp;nbsp;Getting different characters in the middle.&lt;/DIV&gt;&lt;DIV&gt;when &lt;SPAN style="color: #CC0000;"&gt;name = 'D'&lt;/SPAN&gt; Getting D contniously.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;when &lt;SPAN style="color: #CC0000;"&gt;SPDR = 0xAA&lt;/SPAN&gt; getting contniously.&lt;/DIV&gt;&lt;DIV&gt;when &lt;SPAN style="color: #CC0000;"&gt;SPDR = 0xAB&lt;/SPAN&gt; getting different character in the middle.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My assumption is when the characters equivalent binary ends with (LSB) &lt;SPAN style="color: #CC00CC;"&gt;1&lt;/SPAN&gt;&amp;nbsp;I am getting this problem.&lt;/DIV&gt;&lt;DIV&gt;I didnt understand why it is behaving differently&amp;nbsp;Whether &amp;nbsp;problem with my Code. Or problem with my circuits.Or whether my understaning of SPI is not correct.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Kindly Help to solve this problem.&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-01-14&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;04:07 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jan 2008 14:18:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-08GB60/m-p/177523#M12534</guid>
      <dc:creator>Opal</dc:creator>
      <dc:date>2008-01-07T14:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-08GB60/m-p/177524#M12535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I took two DEMO9S08GB60 boards and connected the MOSI/MISO/SS/SPSCLK and gnd wires together and started to play with your code.&lt;/DIV&gt;&lt;DIV&gt;I got the idea that you had mixed some of the signal names together, as I had&amp;nbsp;to rewrite part of it.&lt;/DIV&gt;&lt;DIV&gt;However, I soon could send data from one MCU to another, and it worked just fine.&lt;/DIV&gt;&lt;DIV&gt;Well not all the time. Once the reception went wrong, it stayed wrong.&lt;/DIV&gt;&lt;DIV&gt;So I tried to use the /SS signal to tell the slave when a new byte of data was on its way.&lt;/DIV&gt;&lt;DIV&gt;But it turned out to be difficult in getting the /SS line to wiggle.&lt;/DIV&gt;&lt;DIV&gt;It seems that it wont go high until the line has been idle for at least one character transmission time.&lt;/DIV&gt;&lt;DIV&gt;So I changed that by pulling the I/O lines "by hand".&lt;/DIV&gt;&lt;DIV&gt;It seems to be working now.&lt;/DIV&gt;&lt;DIV&gt;The data transmitted was a string = "ABCD".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In your code you&amp;nbsp;transmitted the received data from the SPI to the SCI.&lt;/DIV&gt;&lt;DIV&gt;As the SPI is generally far more faster than the SCI, that could also be one of the reasons why you got your problems.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am including two photos. The top trace is the MOSI signal. The second is the /SS signal and the third the SPSCLK signal. The first photo shows what happens with the selector AUTOSLAVE set to TRUE.&lt;/DIV&gt;&lt;DIV&gt;In this case the SPI is taking care of the transmission. I had to add a delay between the characters in order to ever see the /SS signal go high.&lt;/DIV&gt;&lt;DIV&gt;On the second picture, I toggle the /SS signal by hand.&lt;/DIV&gt;&lt;DIV&gt;The pulses on the /SS are much shorter now.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To check what was received, you can stop the receiver and check the "error" counter.&lt;/DIV&gt;&lt;DIV&gt;It turned out to be 0 the last times I tried it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The code was written in CodeWarrrior 6.1.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Hope this helps!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Ake&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://www.freescale.com/files/community_files/8BITCOMM/8727_gb60_spi3.zip" rel="nofollow" target="_self"&gt;GB60_SPI3.zip&lt;/A&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by t.dowe on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-10-27&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;12:54 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2008 21:25:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-08GB60/m-p/177524#M12535</guid>
      <dc:creator>Ake</dc:creator>
      <dc:date>2008-01-11T21:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-08GB60/m-p/177525#M12536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Ohoh, It forgot my pictures.&lt;/DIV&gt;&lt;DIV&gt;They are included in the Sources&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Ake&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://www.freescale.com/files/community_files/8BITCOMM/8728_gb60_spi3.zip" rel="nofollow" target="_self"&gt;GB60_SPI3.zip&lt;/A&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by t.dowe on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-10-27&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;12:52 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2008 21:32:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-08GB60/m-p/177525#M12536</guid>
      <dc:creator>Ake</dc:creator>
      <dc:date>2008-01-11T21:32:09Z</dc:date>
    </item>
  </channel>
</rss>

