<?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 Slave questions</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366439#M21171</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello David, Thanks for reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now my SPI Master-Slave&amp;nbsp; works in&amp;nbsp; 9S08AC60.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying Master-Master(fault mode). But i think that &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-align: justify;"&gt; arrangement is imposible. When I debug it&amp;nbsp; the Master with fault mode&amp;nbsp; always stays in slave mode.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But my code in master-slave works now, thanks alot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to my fault mode code is&amp;nbsp; the next. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14211854923783801" jivemacro_uid="_14211854923783801" modifiedtitle="true"&gt;
&lt;P&gt;void SPI_Init_Mstr_F(void)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PTEDD_PTEDD4=1; //Initializate pin (SS) like GPIO as input&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PTED_PTED4=1; //No activity on SPI&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C1=0xD0; /*Set SPI in master mode, active in High, first edge on clock source,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; start data on least significant bit,enables the interrupts generated&lt;/P&gt;
&lt;P&gt;&amp;nbsp; by the SPRF,MODF and SS input for mode fault*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C2=0x10; //Fault mode enable, "NO" Bidirectional&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1BR=0x65; /*Baud rate to 8928.57&amp;nbsp; Baud rate formule:&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; Baud rate = Busclock/((Prescale Divisor)(Rate Divisor))*/&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;interrupt VectorNumber_Vspi1 void Vspi1_isr_MODF(void) // This Responds to “faul mode error” interrupt&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while (!SPI1S_MODF){}; //wait for faul mode error&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // Write your code here&amp;nbsp; before writing to SPI1C1 register&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while (!SPI1S_SPRF){};&amp;nbsp;&amp;nbsp; //Wait until the next byte is received&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTFD = SPI1D; //Save the data of the buffer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTED_PTED4=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; temp=SPI1S_MODF;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C1=0xD0; //Set SPI in master mode, active in High, first edge on clock source,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; //start data on least significant bit,enables the interrupts generated&lt;/P&gt;
&lt;P&gt;&amp;nbsp; //by the SPRF,MODF and SS input for mode fault&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C2=0x10; //Fault mode enable, "NO" Bidirectional&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was looking for mode fault examples. In the document that you mentioned dont have example of fault mode&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Jan 2015 21:41:00 GMT</pubDate>
    <dc:creator>carlosomarharoc</dc:creator>
    <dc:date>2015-01-13T21:41:00Z</dc:date>
    <item>
      <title>SPI Slave questions</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366435#M21167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello! Freescale community&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm learning about SPI and how use the registers.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have initialized the module as slave mode&lt;/P&gt;&lt;P&gt;I suppose when the master wants communicate with the slave, the slave will get the data via interrupt.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is.&amp;nbsp; When the microprocessor get in the Vspir&amp;nbsp; interrupt, he can send information to the master?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the other question is if i have wrote well&amp;nbsp; the interrupt code for the slave. (code below)&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;interrupt VectorNumber_Vspi void Vspi_ISR (void) { &amp;nbsp;&amp;nbsp;&amp;nbsp; byte data;&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; while (!SPIS_SPRF){};&amp;nbsp; // Wait until the next byte is received&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; data = SPID; &amp;nbsp;&amp;nbsp;&amp;nbsp; pixels[0]=data; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Dec 2014 15:25:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366435#M21167</guid>
      <dc:creator>carlosomarharoc</dc:creator>
      <dc:date>2014-12-19T15:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: SPI Slave questions</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366436#M21168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the part number of your MCU or Processor? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 01:46:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366436#M21168</guid>
      <dc:creator>TICS_Fiona</dc:creator>
      <dc:date>2014-12-22T01:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: SPI Slave questions</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366437#M21169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;MC9S08MP16&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 16:52:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366437#M21169</guid>
      <dc:creator>carlosomarharoc</dc:creator>
      <dc:date>2015-01-08T16:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: SPI Slave questions</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366438#M21170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Carlos Omar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;The following figure shows the SPI modules of two MCUs connected in a master-slave arrangement. &lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;During a transfer, the master shifts data out (on the MOSI pin) to the slave while &lt;STRONG&gt;simultaneously&lt;/STRONG&gt; shifting data in (on the MISO pin) from the slave. The transfer effectively exchanges the data that was in the SPI shift registers of the two SPI systems.&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="spi.JPG.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/45557iA8966303425B8119/image-size/large?v=v2&amp;amp;px=999" role="button" title="spi.JPG.jpg" alt="spi.JPG.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;After this exchange of data, an interrupt may be generated. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;Regarding your code, I would like to recommend you a Peripheral Module Quick Reference in which you can find more information and sample code about the SPI Module in the S08 family.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;Please find the document mentioned in the following link:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/user_guide/HCS08QRUG.pdf" style="font-family: Helvetica, sans-serif; font-size: 10pt; line-height: 1.5em;"&gt;http://www.freescale.com/files/microcontrollers/doc/user_guide/HCS08QRUG.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;Hope this information will be useful for you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;Have a good day. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;Best Regards,&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;David Diaz&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #3d3d3d; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 21:00:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366438#M21170</guid>
      <dc:creator>david_diaz</dc:creator>
      <dc:date>2015-01-13T21:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: SPI Slave questions</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366439#M21171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello David, Thanks for reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now my SPI Master-Slave&amp;nbsp; works in&amp;nbsp; 9S08AC60.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying Master-Master(fault mode). But i think that &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-align: justify;"&gt; arrangement is imposible. When I debug it&amp;nbsp; the Master with fault mode&amp;nbsp; always stays in slave mode.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But my code in master-slave works now, thanks alot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to my fault mode code is&amp;nbsp; the next. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14211854923783801" jivemacro_uid="_14211854923783801" modifiedtitle="true"&gt;
&lt;P&gt;void SPI_Init_Mstr_F(void)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PTEDD_PTEDD4=1; //Initializate pin (SS) like GPIO as input&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PTED_PTED4=1; //No activity on SPI&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C1=0xD0; /*Set SPI in master mode, active in High, first edge on clock source,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; start data on least significant bit,enables the interrupts generated&lt;/P&gt;
&lt;P&gt;&amp;nbsp; by the SPRF,MODF and SS input for mode fault*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C2=0x10; //Fault mode enable, "NO" Bidirectional&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1BR=0x65; /*Baud rate to 8928.57&amp;nbsp; Baud rate formule:&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; Baud rate = Busclock/((Prescale Divisor)(Rate Divisor))*/&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;interrupt VectorNumber_Vspi1 void Vspi1_isr_MODF(void) // This Responds to “faul mode error” interrupt&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while (!SPI1S_MODF){}; //wait for faul mode error&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // Write your code here&amp;nbsp; before writing to SPI1C1 register&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while (!SPI1S_SPRF){};&amp;nbsp;&amp;nbsp; //Wait until the next byte is received&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTFD = SPI1D; //Save the data of the buffer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTED_PTED4=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; temp=SPI1S_MODF;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C1=0xD0; //Set SPI in master mode, active in High, first edge on clock source,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; //start data on least significant bit,enables the interrupts generated&lt;/P&gt;
&lt;P&gt;&amp;nbsp; //by the SPRF,MODF and SS input for mode fault&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SPI1C2=0x10; //Fault mode enable, "NO" Bidirectional&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was looking for mode fault examples. In the document that you mentioned dont have example of fault mode&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 21:41:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/SPI-Slave-questions/m-p/366439#M21171</guid>
      <dc:creator>carlosomarharoc</dc:creator>
      <dc:date>2015-01-13T21:41:00Z</dc:date>
    </item>
  </channel>
</rss>

