<?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>S12 / MagniV MicrocontrollersのトピックRe: SPI interfacing</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interfacing/m-p/191923#M7499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you look at the user's guide for the&amp;nbsp;mc9s12xdt512, each SPI port can be set to one of two sets of 4 pins, which is taken care of by MODRR (Module Routing Register). &amp;nbsp;Make sure that both of your SPI ports are set to the correct bank of 4 pins by setting or clearing the correct bit of MODRR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a similar issue, although I was only receiving, I wasn't seeing SCLK pulses on an oscilloscope when I knew I was transmitting, and had a tough time finding out which bank 0 sent it to, and which 1 sent it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 14px;"&gt;Look up the PIM's block user's guide (Port Integration Module) and look up MODRR for your port and check if it's set for your bank of pins.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 14px;"&gt;I'd love if Freescale took care there being no obvious correlation between the two in the user's guide(s) unless you really pour over them for a while. &amp;nbsp;Everything else is fairly well documented.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Jan 2012 05:00:38 GMT</pubDate>
    <dc:creator>PLacerenza</dc:creator>
    <dc:date>2012-01-21T05:00:38Z</dc:date>
    <item>
      <title>SPI interfacing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interfacing/m-p/191922#M7498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey there. am working on SPI interface between two microcontrollers. mc9s12xdt512. help me out with the code.&lt;/P&gt;&lt;P&gt;#include /* common defines and macros */&lt;/P&gt;&lt;P&gt;&amp;nbsp;#include /* derivative information */&lt;/P&gt;&lt;P&gt;#pragma LINK_INFO DERIVATIVE "mc9s12xdt512"&lt;/P&gt;&lt;P&gt;&amp;nbsp;#include "main_asm.h" /* interface to the assembly module */&lt;/P&gt;&lt;P&gt;void main(void)&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;unsigned char x;&lt;/P&gt;&lt;P&gt;SPI0BR=0x20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;SPI0CR1=0x54;&lt;/P&gt;&lt;P&gt;&amp;nbsp;SPI0CR2=0x0;&lt;BR /&gt;WOMS=0x0;&lt;/P&gt;&lt;P&gt;for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;while(!(SPI0SR &amp;amp; SPI0SR_SPTEF_MASK));&lt;/P&gt;&lt;P&gt;&amp;nbsp;SPI0DR='B';&lt;/P&gt;&lt;P&gt;while(!(SPI0SR &amp;amp; SPI0SR_SPIF_MASK))&lt;/P&gt;&lt;P&gt;&amp;nbsp;x=SPI0DR;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;thisis my code for transmitting a character. when i run it on a full chip simulation mode, i can see the character 'B' at SPI0DR. but when i run it on the controllers, i dannot see any thing at SPI0DR. on the recieveing side my code is&lt;/P&gt;&lt;P&gt;&amp;nbsp;void main(void)&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;unsigned char x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;SPI0BR=0x20;&lt;/P&gt;&lt;P&gt;SPI0CR1=0x44;&lt;/P&gt;&lt;P&gt;&amp;nbsp;SPI0CR2=0x0;&lt;/P&gt;&lt;P&gt;WOMS=0x0;&lt;/P&gt;&lt;P&gt;for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;while(!(SPI0SR &amp;amp; SPI0SR_SPTEF_MASK));&lt;/P&gt;&lt;P&gt;&amp;nbsp;SPI0DR=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;while(!(SPI0SR &amp;amp; SPI0SR_SPIF_MASK))&lt;/P&gt;&lt;P&gt;&amp;nbsp;x=SPI0DR;&lt;/P&gt;&lt;P&gt;} } my status register reads 20. and nothing at SPI0DR. help me out&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Dec 2011 20:29:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interfacing/m-p/191922#M7498</guid>
      <dc:creator>tormentor</dc:creator>
      <dc:date>2011-12-22T20:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interfacing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interfacing/m-p/191923#M7499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you look at the user's guide for the&amp;nbsp;mc9s12xdt512, each SPI port can be set to one of two sets of 4 pins, which is taken care of by MODRR (Module Routing Register). &amp;nbsp;Make sure that both of your SPI ports are set to the correct bank of 4 pins by setting or clearing the correct bit of MODRR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a similar issue, although I was only receiving, I wasn't seeing SCLK pulses on an oscilloscope when I knew I was transmitting, and had a tough time finding out which bank 0 sent it to, and which 1 sent it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 14px;"&gt;Look up the PIM's block user's guide (Port Integration Module) and look up MODRR for your port and check if it's set for your bank of pins.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 14px;"&gt;I'd love if Freescale took care there being no obvious correlation between the two in the user's guide(s) unless you really pour over them for a while. &amp;nbsp;Everything else is fairly well documented.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Jan 2012 05:00:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interfacing/m-p/191923#M7499</guid>
      <dc:creator>PLacerenza</dc:creator>
      <dc:date>2012-01-21T05:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interfacing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interfacing/m-p/191924#M7500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, and welcome to the forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, to clarify some terminology -&lt;/P&gt;&lt;P&gt;The SPI module may be configured as either a master, or a slave.&amp;nbsp; Both configurations are capable of handling data flow in both directions simultaneously.&amp;nbsp; For the master, data is sent via MOSI, and received via MISO.&amp;nbsp; For the slave end, the roles are reversed.&amp;nbsp; The master end always initiates&amp;nbsp;each data transfer, and generates the clock pulses required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code snippet that you have shown is suitable for the SPI&amp;nbsp;master, where a send byte is initiated, and the received value is available&amp;nbsp;once the SPIF flag becomes set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the SPI slave, the operation is quite different.&amp;nbsp; Any data to be returned to the master on the &lt;U&gt;next&lt;/U&gt; transfer needs to be loaded to the buffer prior to SS becoming active.&amp;nbsp; Following the receipt of data from the master (and the return of the data already within the buffer), the SPIF flag will become set.&amp;nbsp; If data is to be returned in response, this will&amp;nbsp;commence on the next transfer.&amp;nbsp; This may require that the master allow adequate time for the slave to process the data, before initiating the transfer (usually&amp;nbsp;with "dummy" send bytes).&amp;nbsp; Alternatively, the slave might signal back to the master when it is ready, or requires some attention,&amp;nbsp;using an extra GPIO line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To minimize the delay within the master, SPI interrupts are freqently used for the SPI slave.&amp;nbsp; If the response requires a sequence of more than one byte, the double bufferering capability of the SPI module can be put to use.&amp;nbsp; A second byte can be loaded to the buffer, prior to the first byte being returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For communications between two MCUs, it is also possible for each MCU to default to slave mode, and only become a master when it requires to initiate an action (a multi-master situation).&amp;nbsp; But this method requires more complex code to handle potential conflicts.&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>Sat, 21 Jan 2012 12:59:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interfacing/m-p/191924#M7500</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-01-21T12:59:58Z</dc:date>
    </item>
  </channel>
</rss>

