<?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: HCS08DZ60, peculiar SPI problem</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179216#M12830</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I have tried that as well, I get the same phenomenon. There is likely some flag somewhere which doesn't get cleared as it should, though I fail to see where. Perhaps I need to dummy read both the status + data first, before sending anything?&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Jan 2008 21:37:41 GMT</pubDate>
    <dc:creator>Lundin</dc:creator>
    <dc:date>2008-01-14T21:37:41Z</dc:date>
    <item>
      <title>HCS08DZ60, peculiar SPI problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179214#M12828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm using HCS08DZ60 on EVB9S08DZ from Softec, with CW6.0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The HCS08 is master and we are trying to contact a SPI slave device but cannot get it working. On the hardware level, everything is working correctly. The MOSI line sends the correct data and I get the correct response from the external circuit on the MISO pin of the mcu.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I read the SPI data register, the data shows up as 0xFF. That is when I have SSOE=1, if I set the /SS pin manually instead, the SPI data shows up as 0x00.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, if I let the program run and send several commands, I do get the right values in the SPID. So there seems to be a problem with the first byte of data sent/received. I have tried various clock settings with CPHA and CPOL, but no combination works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void SPI_init ( SPI_Baudrate baud){&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SPIC1 = 0x5E; //SPIE=0;SPE=1;SPTIE=0;MSTR=1;CPOL=1;CPHA=1;SSOE=1;LSBFE=0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SPIC2 = 0x12; //0; 0; 0; MODFEN=1 ; BIDIROE=0 ;0 ;SPISWAI=1 ;SPCO=0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPIBR = (uint8)baud;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;uint8 SPI_transfer(uint8 data1, uint8 data2){&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;volatile uint8 x;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// PTED = 0x00; // SS low&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while(SPIS_SPTEF == 0) //wait until transmitter empty&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPID = data1; //send data1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while(SPIS_SPTEF == 0) //wait until transmitter empty&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SPID = data2; //send data2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while (SPIS_SPRF == 0) //wait until receiver is full&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x= SPID; //read data register&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// PTED = 0x04; // SS high&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return x;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I remember similar problems on the HCS12, which was then caused by silicon bugs. I can't find any errata for the S08 SPI though, is there one for silicon mask 1M05C?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2008 17:46:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179214#M12828</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-01-14T17:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08DZ60, peculiar SPI problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179215#M12829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Lundin,&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;Your code appears to&amp;nbsp;send two bytes in succession, but reads only a single return byte (after both have been sent or buffered).&amp;nbsp; An overrun condition is possibly occurring, that may cause subsequent data to be missed.&amp;nbsp; Both return bytes should be read, even if the data is to be discarded.&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;The safest approach is to send only a single byte at a time, and wait until SPRF flag becomes set before reading the data byte (also clears the flag), and then sending the next byte.&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;After you first enable the SPI module, it is necessary to read SPIS, before sending the first byte.&amp;nbsp; But you appear to be already doing this by virtue of the while loop that tests the SPTEF flag.&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, 14 Jan 2008 20:55:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179215#M12829</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-01-14T20:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08DZ60, peculiar SPI problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179216#M12830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I have tried that as well, I get the same phenomenon. There is likely some flag somewhere which doesn't get cleared as it should, though I fail to see where. Perhaps I need to dummy read both the status + data first, before sending anything?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2008 21:37:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179216#M12830</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-01-14T21:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08DZ60, peculiar SPI problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179217#M12831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Are you using his safe suggestion of reading the first data byte only after SPRF is set?&amp;nbsp; If not this could certainly be the problem.&amp;nbsp; I would&amp;nbsp;double check that all the&amp;nbsp;timing is right by adding&amp;nbsp;a few dummy waits inbetween some of the commands just to double check.&amp;nbsp; I have been using the DZ60 on a few products for a while now, 2 with SPI and haven't had any problems.&amp;nbsp; Most of useage has been in sending data instead of requesting though, so I probably wouldn't have seen a problem of reading the first data 2 data bytes.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2008 23:08:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179217#M12831</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-01-14T23:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08DZ60, peculiar SPI problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179218#M12832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I take it there is no errata for the DZ60?&lt;BR /&gt;&lt;BR /&gt;After testing various combinations of dummy reads/writes, it seems as if the cause of the problem is a timing problem in the external slave IC. As one might have suspected at first... though, I suppose it doesn't hurt to check here so I don't spend weeks searching for something that is a known issue. &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks everyone who replied!&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2008 00:11:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179218#M12832</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-01-15T00:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08DZ60, peculiar SPI problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179219#M12833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;SPI on the DZ60 works for me &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt; Just using it for EEprom access, but all seems fine.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2008 02:13:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08DZ60-peculiar-SPI-problem/m-p/179219#M12833</guid>
      <dc:creator>Bruce_andrew</dc:creator>
      <dc:date>2008-01-22T02:13:30Z</dc:date>
    </item>
  </channel>
</rss>

