<?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: Avoiding the new initial status read before using the S08 SPI in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139458#M5341</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello unknown,&lt;BR /&gt;&lt;BR /&gt;You have master side transmit interrupts enabled but your transmit function does not look like an interrupt function. Even if it is, don't implement it as an interrupt just yet get it working first then do it as an interrupt later.&lt;BR /&gt;Change your master side init of SPIC1 to 0x54 and see how you go then.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Jan 2009 17:10:42 GMT</pubDate>
    <dc:creator>peg</dc:creator>
    <dc:date>2009-01-29T17:10:42Z</dc:date>
    <item>
      <title>Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139452#M5335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;Starting with the S08 there is a new restriction that requires you to read the SPI status register to test for transmit buffer empty before you write to the data register.&lt;/DIV&gt;&lt;DIV&gt;It was not necessary with the older HC08/05's&lt;/DIV&gt;&lt;DIV&gt;This issue has been discussed before here:&lt;/DIV&gt;&lt;DIV&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fforums.freescale.com%2Ffreescale%2Fboard%2Fmessage%3Fboard.id%3D8BITCOMM%26message.id%3D5009" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;message.id=5009&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In that post I suggested to test the SPTEF bit in the SPIS on every write as this is how I had converted a HC908GP32 project into a GT16. I came up against this problem again (converting GP32 code to GT16A) This time the SPI is much busier, previously it was only used on initialisation and manual test read.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It is really only necessary to do this&amp;nbsp;before the first ever read as the check for SPRF during the transmit/recieve will cover the requirement on subsequent uses.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I found the best way to achieve this is to do a read of the SPIS right when you setup the SPI, like this:&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;*********** Setup SPI for EEPROM ********************************************&amp;nbsp; MOV #(mSPE|mMSTR),SPIC1 ;Enable SPI as master 0,0&amp;nbsp; CLR SPIC2&amp;nbsp; MOV #mSPR0,SPIBR&amp;nbsp; ;/4 = 5MHz&amp;nbsp; LDA SPIS&amp;nbsp;&amp;nbsp; ;dummy SPTEF check&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;This way you can use a normal SPI send/recieve routine like this:&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;OUTBYTE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA SPID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;put data in SPI register&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; BRCLR SPRF,SPIS,*&amp;nbsp; ;wait till sent (or recieved)&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; LDA SPID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;read returned value&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; RTS&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;This avoids the unecessary check of SPTEF every time while keeping things where they should be found.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2007 17:59:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139452#M5335</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-07-09T17:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139453#M5336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Peg,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Thank you for a timely reminder&amp;nbsp;. . . I had completely forgotten about&amp;nbsp;that one.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Fortunately, when I have previously suggested SPI code on this forum, I normally include the extra test of SPTEF, with the consequent penalty of 5 cycles for HCS08.&amp;nbsp; But at least it means the function will always work on&amp;nbsp;whatever MCU, without the need to be particularly concerned about the process of SPI initialisation.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Perhaps this is&amp;nbsp;appropriate for the forum, since the few additional cycles are probably inconsequential for most projects.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2007 23:35:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139453#M5336</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-07-09T23:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139454#M5337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello Bigmac,&lt;BR /&gt;&lt;BR /&gt;I am working on SPI Driver for MC9S08DZ60 microcontroller.&amp;nbsp; I have one master and one slave, both master and slave are of same&amp;nbsp; microcontrollers( MC9S08DZ60). I have a problem in receiving a byte at the slave side. Im not sure also whether the data byte has been sent or not. Following is my code.&lt;BR /&gt;&lt;BR /&gt;Transmit function at Master side:&lt;BR /&gt;---------------------------------------&lt;BR /&gt;&lt;BR /&gt;void spi_tx(void) &lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fl_dummy;;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!SPIS_SPTEF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fl_dummy = SPIS;&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; //Clear SPTEF flag&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPID = 0x06;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while((SPIS &amp;amp; 0x80) != 0x80);&amp;nbsp;&amp;nbsp; //Wait for transmission to complete&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Receive function at Slave side:&lt;BR /&gt;---------------------------------------&lt;BR /&gt;&lt;BR /&gt;int spi_rx(void) &lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; int temp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; temp = SPIS;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; while((SPIS &amp;amp; 0x80) != 0x80);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; temp = SPID;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return temp;&lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;This micro controller is from&amp;nbsp; HCS08&amp;nbsp; family.&lt;BR /&gt;&lt;BR /&gt;Can u please lemme knw what and where the prblm exists. &lt;BR /&gt;Its very urgent. Kindly reply me ASAP.&lt;BR /&gt;Thank you.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;xxxx&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jan 2009 21:42:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139454#M5337</guid>
      <dc:creator>Unknown</dc:creator>
      <dc:date>2009-01-28T21:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139455#M5338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Unknown,&lt;BR /&gt;&lt;BR /&gt;Does your transmit routine hang?&lt;BR /&gt;If not, your data is sent!&lt;BR /&gt;&lt;BR /&gt;Does your receive routine hang?&lt;BR /&gt;If not, what is wrong with the data that you're getting?&lt;BR /&gt;&lt;BR /&gt;How have you initialised each SPI module?&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 06:36:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139455#M5338</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2009-01-29T06:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139456#M5339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;FONT face="Arial" size="2"&gt;Hi Peg,&lt;BR /&gt;&lt;BR /&gt;When i run the code at one shot without any brkpoints(at master side) it will come out of transmit function, it does not hang. But when I run step by step by putting break points it will never come out of the below line.&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&amp;gt;&amp;lt;meta name="ProgId" content="Word.Document"&amp;gt;&amp;lt;meta name="Generator" content="Microsoft Word 11"&amp;gt;&amp;lt;meta name="Originator" content="Microsoft Word 11"&amp;gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:WordDocument&gt;  &lt;w:View&gt;Normal&lt;/w:View&gt;  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;  &lt;w:PunctuationKerning&gt;&lt;/w:PunctuationKerning&gt;  &lt;w:ValidateAgainstSchemas&gt;&lt;/w:ValidateAgainstSchemas&gt;  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;  &lt;w:Compatibility&gt;   &lt;w:BreakWrappedTables&gt;&lt;/w:BreakWrappedTables&gt;   &lt;w:SnapToGridInCell&gt;&lt;/w:SnapToGridInCell&gt;   &lt;w:WrapTextWithPunct&gt;&lt;/w:WrapTextWithPunct&gt;   &lt;w:UseAsianBreakRules&gt;&lt;/w:UseAsianBreakRules&gt;   &lt;w:DontGrowAutofit&gt;&lt;/w:DontGrowAutofit&gt;  &lt;/w:Compatibility&gt;  &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt; &lt;/w:WordDocument&gt;&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt; &lt;/w:LatentStyles&gt;&lt;/xml&gt;&lt;![endif]--&gt;ection1;} --&amp;gt; &lt;!--[if gte mso 10]&gt;&lt;style&gt; /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}&lt;/style&gt;&lt;![endif]--&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN style=""&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;while((SPIS &amp;amp; 0x80) != 0x80);&lt;SPAN style=""&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt; (in&amp;nbsp; Transmit&amp;nbsp; function)&lt;BR /&gt;&lt;BR /&gt;Im using CRO to test the same. I hav connected 4 probes to 4 corresponding pins of master(No connections between master and slave at this point). But im not able to see the data on the bus.&lt;BR /&gt;&lt;BR /&gt; When I run at one shot then the execution hangs at the receive function (Slave side),at the below line&lt;BR /&gt;&lt;/FONT&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&amp;gt;&amp;lt;meta name="ProgId" content="Word.Document"&amp;gt;&amp;lt;meta name="Generator" content="Microsoft Word 11"&amp;gt;&amp;lt;meta name="Originator" content="Microsoft Word 11"&amp;gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:WordDocument&gt;  &lt;w:View&gt;Normal&lt;/w:View&gt;  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;  &lt;w:PunctuationKerning&gt;&lt;/w:PunctuationKerning&gt;  &lt;w:ValidateAgainstSchemas&gt;&lt;/w:ValidateAgainstSchemas&gt;  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;  &lt;w:Compatibility&gt;   &lt;w:BreakWrappedTables&gt;&lt;/w:BreakWrappedTables&gt;   &lt;w:SnapToGridInCell&gt;&lt;/w:SnapToGridInCell&gt;   &lt;w:WrapTextWithPunct&gt;&lt;/w:WrapTextWithPunct&gt;   &lt;w:UseAsianBreakRules&gt;&lt;/w:UseAsianBreakRules&gt;   &lt;w:DontGrowAutofit&gt;&lt;/w:DontGrowAutofit&gt;  &lt;/w:Compatibility&gt;  &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt; &lt;/w:WordDocument&gt;&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt; &lt;/w:LatentStyles&gt;&lt;/xml&gt;&lt;![endif]--&gt;ection1;} --&amp;gt; &lt;!--[if gte mso 10]&gt;&lt;style&gt; /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}&lt;/style&gt;&lt;![endif]--&gt; &lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; while((SPIS &amp;amp; 0x80) != 0x80);&amp;nbsp; (in receive function).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;So kindly let me know the prblm.&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;Regards&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;xxx.&lt;BR /&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;FONT face="Arial" size="2"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 14:40:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139456#M5339</guid>
      <dc:creator>Unknown</dc:creator>
      <dc:date>2009-01-29T14:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139457#M5340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;FONT face="Arial" size="2"&gt;Hi Peg,&lt;BR /&gt;&lt;BR /&gt;When i run the code at one shot without any brkpoints(at master side) it will come out of transmit function, it does not hang. But when I run step by step by putting break points it will never come out of the below line.&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="msg_text_cell" colspan="2" rowspan="2" style="text-align: justify;" valign="top" width="100%"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;   Normal  0      false  false  false                     MicrosoftInternetExplorer4 &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;/xml&gt;&lt;![endif]--&gt;ection1;} --&amp;gt; &lt;!--[if gte mso 10]&gt;&lt;style&gt; /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}&lt;/style&gt;&lt;![endif]--&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN style=""&gt;&amp;nbsp;&lt;B&gt;&amp;nbsp;&lt;/B&gt;&lt;/SPAN&gt;&lt;B&gt;while((SPIS &amp;amp; 0x80) != 0x80);&lt;SPAN style=""&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/B&gt;&lt;/SPAN&gt; &lt;B&gt;(in&amp;nbsp; Transmit&amp;nbsp; function)&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;Im using CRO to test the same. I hav connected 4 probes to 4 corresponding pins of master(No connections between master and slave at this point). But im not able to see the data on the bus.&lt;BR /&gt;&lt;BR /&gt; When I run at one shot then the execution hangs at the receive function (Slave side),at the below line&lt;BR /&gt;&lt;/FONT&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;   Normal  0      false  false  false                     MicrosoftInternetExplorer4 &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;/xml&gt;&lt;![endif]--&gt;ection1;} --&amp;gt; &lt;!--[if gte mso 10]&gt;&lt;style&gt; /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}&lt;/style&gt;&lt;![endif]--&gt; &lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&lt;B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/B&gt;&lt;/SPAN&gt; &lt;B&gt;while((SPIS &amp;amp; 0x80) != 0x80);&amp;nbsp; (in receive function).&lt;/B&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;BR /&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;Yes I have initialised the SPI modules at both sides. Below is the code.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;Master Side:&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;-------------&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;void spi_init(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SPIC1 = 0x74;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SPIC2 = 0x00;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SPIBR = 0x00;&amp;nbsp; //4MHz: Half of the bus clock(8MHz)&lt;BR /&gt;}&lt;BR /&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;Slave Side:&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;-----------&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;void spi_init(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SPIC1 = 0x44;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SPIC2 = 0x00;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;So kindly let me know the prblm.&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;Regards&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal" style=""&gt;&lt;FONT face="Arial" size="2"&gt;xxx.&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 14:45:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139457#M5340</guid>
      <dc:creator>Unknown</dc:creator>
      <dc:date>2009-01-29T14:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139458#M5341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello unknown,&lt;BR /&gt;&lt;BR /&gt;You have master side transmit interrupts enabled but your transmit function does not look like an interrupt function. Even if it is, don't implement it as an interrupt just yet get it working first then do it as an interrupt later.&lt;BR /&gt;Change your master side init of SPIC1 to 0x54 and see how you go then.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 17:10:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139458#M5341</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2009-01-29T17:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139459#M5342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello Peg,&lt;BR /&gt;&lt;BR /&gt;I have tried with SPIC1 = 0x54.&lt;BR /&gt;Even though its not working. I cannot see the data on the MOSI line in the CRO.&lt;BR /&gt;Im using polling method instead of interrupt.&lt;BR /&gt;&lt;BR /&gt;I can see the SCLK on the bus, but not the data. I guess problem is in the transmit function.&lt;BR /&gt;But not sure where? could u pls help me out.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;XXX.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 17:51:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139459#M5342</guid>
      <dc:creator>Unknown</dc:creator>
      <dc:date>2009-01-29T17:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139460#M5343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Once you have the SPI initialised properly, transmitting is simply a matter of writing to the SCID. You only get activity on the SCLK line when data is being transmitted. If you don't see any activity on the data (at the same time you are seeing CLK's) you are sending a 0x00 or 0xFF or your hardware is broken.&lt;BR /&gt;&lt;BR /&gt;If you go back to the assembly example at the top of the thread, this is all you need to send and recieve on SPI.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2009 18:18:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139460#M5343</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2009-01-29T18:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139461#M5344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Peg,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for the information.&lt;BR /&gt;SPI is working now.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;xxxx&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 15:40:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139461#M5344</guid>
      <dc:creator>Unknown</dc:creator>
      <dc:date>2009-02-06T15:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139462#M5345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, I've read this thread a number of times as well as others in the forum pertaining to SPI on the HC9S08 products (I'm using the MC9S08LG32). Since the instuctions provided in this thread are clear, I am thinking whether my problem with SPI lies with CodeWarrior. I am interfacing the uP with an A/D converter (ADS1241). On this device the "POL" pin is tied to ground. I could not find info in the datasheet for phase, so I left this at 0. Here is my code:&lt;BR /&gt;SCGC2_SPI = 1; // System Clock Gating Control Register to enable clocking to SPI;&lt;BR /&gt;SPIC1 = 0x50; // Enable SPI interface and uP as Master&lt;BR /&gt;SPIC2 = 0x00;&lt;BR /&gt;SPIBR = 0x45;&lt;BR /&gt;dummy = SPIS; // Read SPIS&lt;BR /&gt;PTED_PTED5 = 0; // PTE5 is GPIO to enable device&lt;BR /&gt;//&lt;BR /&gt;SPID = 0x11; // Send first data byte (instruction to A/D)&lt;BR /&gt;while (!SPIS_SPRF); // Wait for SPRF to load&lt;BR /&gt;dummy = SPID; // Read SPID&lt;BR /&gt;SPID = 0x01; // Send 2nd data byte (2nd part of instruction)&lt;BR /&gt;while (!SPIS_SPRF); // Wait again&lt;BR /&gt;dummy = SPID; // Read SPID (no info should be here)&lt;BR /&gt;SPID = 0xff; // Send dummy byte to A/D&lt;BR /&gt;while (!SPIS_SPRF); // Wait again&lt;BR /&gt;dummy = SPID; // Should be real feedback here&lt;BR /&gt;&lt;BR /&gt;Using CodeWarrior, I look at the SPID in the memory window. In continually reads 0xFF. When I single step thru the code, the program hangs on the while statements. Running the code full-speed works fine; however, I still get only FF as a response from the A/D (looking at SPID and the variable dummy in the memory window of CW). Any comments would be appreciated.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Dec 2009 02:36:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139462#M5345</guid>
      <dc:creator>Thunder</dc:creator>
      <dc:date>2009-12-19T02:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139463#M5346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi again, it seems to have been a HW problem (my MISO line wasn't even connected to the A/D device).&amp;nbsp; After soldering in a jumper, it seems to be working.&amp;nbsp; Still curious though why the read response would be 0xFF each time.&amp;nbsp;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Dec 2009 04:35:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139463#M5346</guid>
      <dc:creator>Thunder</dc:creator>
      <dc:date>2009-12-19T04:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139464#M5347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Thunder and welcome to the fora.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SPI simply clocks in the level present on the MISO pin at the appropriate clock transition. If an unconnected pin happens to assume a high level, you will see 0xFF as the byte clocked in. No mystery here!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Dec 2009 04:55:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139464#M5347</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2009-12-19T04:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Avoiding the new initial status read before using the S08 SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139465#M5348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmmm.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just got caught by this again. Doing another conversion from GP32 to GT16A.&lt;/P&gt;&lt;P&gt;I was using the debugger to find another issue and this caused the problem not to occur. Only when I went back to standalone running did it hang due to the failure to read the status register first. On the debugger it runs OK. The debugger was not displaying the status register at the time so I do not know why the debugger "fixes" the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Mar 2010 17:12:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Avoiding-the-new-initial-status-read-before-using-the-S08-SPI/m-p/139465#M5348</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2010-03-17T17:12:57Z</dc:date>
    </item>
  </channel>
</rss>

