<?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 bus Slave Select on HCS08QE</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-bus-Slave-Select-on-HCS08QE/m-p/188435#M14357</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Renee,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You do not say what slave device to which&amp;nbsp;the master is connected?&amp;nbsp; Maybe you should check that there is not a pin conflict with the slave connection to SS.&amp;nbsp;&amp;nbsp;Perhaps you have the high drive strength setting when you bit bang, which would not apply to the automatic SS case, so you might then not notice&amp;nbsp;any conflict.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are some situations where you&amp;nbsp;require to bit bang the SS output, most often when the slave requirement is for SS to remain active low for multiple SPI bytes, e.g serial EEPROM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There will be only a marginal effect on overall timing, likely amounting to&amp;nbsp;five cycles per SS transition.&amp;nbsp; Keep in mind that the overhead associated with the execution of your SPI_send_byte() function will mean at least 50-60 cycles&amp;nbsp;for the fastest SPI clock rate, maybe more.&amp;nbsp; So the effect of the additional bit banging instructions would be minor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you are completing&amp;nbsp;transfer of a single byte at a time,&amp;nbsp;the SPTEF flag will always be set when you enter the function, so the test of the SPTEF flag could be eliminated (with the potential saving of five cycles).&amp;nbsp; However, it is then essential to read SPIS during initialisation (as you are currently&amp;nbsp;doing).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Depending on the requirements of your slave device, another&amp;nbsp;possibility could be to utilise CPHA = 1.&amp;nbsp; Then it is not necessary to raise and lower SS between bytes - all SPI timing is referenced to the first SPI clock edge for each byte transfer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Mar 2011 23:04:07 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2011-03-04T23:04:07Z</dc:date>
    <item>
      <title>SPI bus Slave Select on HCS08QE</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-bus-Slave-Select-on-HCS08QE/m-p/188434#M14356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;When I execute my code Slave select isn't going low at the correct time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the code below I see the proper values transmitted out MOSI (And the clock is correct) but SS_n is NOT encapsulating the data, it is shifted forward in time to about the 2nd clock and then falling.&amp;nbsp;&amp;nbsp;&amp;nbsp; In other words SS_n drops after the first 2 bits are transmitted.&lt;/P&gt;&lt;P&gt;Yet the datasheet shows that if the SPI i/f is set up as master that SS_n should drop 1/2 tSPSCLK before the first clock edge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know what the datasheet is referring to when it says DDS7=1?&amp;nbsp; I am referring to the figure on page 23 of the "MC9S08QE8 Series Data Sheet, Rev. 7".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I searched both the reference manual and the datasheet for DDS and found nothing close other than PTDDS which is Port D's drive strength register.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you notice I have a couple places where I have commented out code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //PTBD_PTBD5 = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //PTBD_PTBD5 = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I change SPIC2 from 0x12 to 0x02 (In SPI_Init) and uncomment these two lines in the "SPI_Send_byte" function then SS_n works.&amp;nbsp;&amp;nbsp; -BUT- I shouldn't have to do this since there is dedicated hardware in the chip to handle it for us.&amp;nbsp;&amp;nbsp; (And I believe it would run slower than the dedicated hardware&amp;nbsp; - once I find what I am doing incorrectly.)&amp;nbsp; All this is doing is making SS_n GPIO and I am bit banging it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am assuming that SS_n is driven high and low (i.e. I don't need a pulldown on that line)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;BR /&gt;#include "derivative.h" /* include peripheral declarations */&lt;BR /&gt;&lt;BR /&gt;#ifdef __cplusplus&lt;BR /&gt;extern "C"&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;/****************************************&lt;BR /&gt;**&lt;BR /&gt;**&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Subroutines Definition&lt;BR /&gt;**&lt;BR /&gt;****************************************/&lt;BR /&gt;&lt;BR /&gt;void SPI_Init(void);&lt;BR /&gt;void SPI_Send_byte(unsigned char data);&lt;BR /&gt;#define SPI_SS&amp;nbsp;&amp;nbsp;&amp;nbsp; PTBD_PTBD5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Slave Select&lt;BR /&gt;#define _SPI_SS&amp;nbsp;&amp;nbsp; PTBDD_PTBDD5&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;void main(void) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SPI_Init();&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( ; ; )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; SPI_Send_byte(0xF1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_Send_byte(0x72);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } // end for&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void SPI_Init(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SPI_SS = 1;&lt;BR /&gt;&amp;nbsp; _SPI_SS= 1;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPIC1 = 0x00;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPIC2 = 0x12;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPIBR = 0x00;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void)(SPIS==0U);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPIC1 = 0x52;&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;void SPI_Send_byte(unsigned char u8Data)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int dummy;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while(!SPIS_SPTEF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;dummy = SPIS;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//PTBD_PTBD5 = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SPID=u8Data;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while(!SPIS_SPRF);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;dummy = SPID;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//PTBD_PTBD5 = 1;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Renee&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 05:09:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-bus-Slave-Select-on-HCS08QE/m-p/188434#M14356</guid>
      <dc:creator>rlstraney</dc:creator>
      <dc:date>2011-03-04T05:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: SPI bus Slave Select on HCS08QE</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-bus-Slave-Select-on-HCS08QE/m-p/188435#M14357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Renee,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You do not say what slave device to which&amp;nbsp;the master is connected?&amp;nbsp; Maybe you should check that there is not a pin conflict with the slave connection to SS.&amp;nbsp;&amp;nbsp;Perhaps you have the high drive strength setting when you bit bang, which would not apply to the automatic SS case, so you might then not notice&amp;nbsp;any conflict.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are some situations where you&amp;nbsp;require to bit bang the SS output, most often when the slave requirement is for SS to remain active low for multiple SPI bytes, e.g serial EEPROM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There will be only a marginal effect on overall timing, likely amounting to&amp;nbsp;five cycles per SS transition.&amp;nbsp; Keep in mind that the overhead associated with the execution of your SPI_send_byte() function will mean at least 50-60 cycles&amp;nbsp;for the fastest SPI clock rate, maybe more.&amp;nbsp; So the effect of the additional bit banging instructions would be minor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you are completing&amp;nbsp;transfer of a single byte at a time,&amp;nbsp;the SPTEF flag will always be set when you enter the function, so the test of the SPTEF flag could be eliminated (with the potential saving of five cycles).&amp;nbsp; However, it is then essential to read SPIS during initialisation (as you are currently&amp;nbsp;doing).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Depending on the requirements of your slave device, another&amp;nbsp;possibility could be to utilise CPHA = 1.&amp;nbsp; Then it is not necessary to raise and lower SS between bytes - all SPI timing is referenced to the first SPI clock edge for each byte transfer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 23:04:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-bus-Slave-Select-on-HCS08QE/m-p/188435#M14357</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2011-03-04T23:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: SPI bus Slave Select on HCS08QE</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-bus-Slave-Select-on-HCS08QE/m-p/188436#M14358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mac,&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp; The hardware I am using is the DEMO9S08QE8 board. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When responding to your message I found the problem.&lt;/P&gt;&lt;P&gt;I thought that they had wired the four SPI port pins only over to the 56 pin MCU connector.&amp;nbsp;&amp;nbsp; They did for MOSI MISO and SPSCLK but SS_n also was wired to a Piezo Buzzer.&amp;nbsp; Apparently the buzzer has enough capacitance to keep the SS_n trace from discharging fast enough.&amp;nbsp; (So on my logic analyzer SS_n seemed to take way to long to go to logic 0. )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Buzzer can be disconnected by removing a jumper (J19) and now SS_n drops where it should.&amp;nbsp; Somehow I didn't see that it was connected to the buzzer.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Renee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Mar 2011 02:19:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-bus-Slave-Select-on-HCS08QE/m-p/188436#M14358</guid>
      <dc:creator>rlstraney</dc:creator>
      <dc:date>2011-03-05T02:19:29Z</dc:date>
    </item>
  </channel>
</rss>

