<?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 MC9S12DG256 SPI with multiple slaves in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330087#M10433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;MC9S12DG256 SPI with two slave devices: DAC TLC5618 and ADC AD7888.&lt;/P&gt;&lt;P&gt;They are both connected to SPI0, but they require different SPI configurations (for TLC5618 CPHA=0, for AD7888 CPHA=1).&lt;/P&gt;&lt;P&gt;I found in the MC9S12DG256 datasheet that "In master mode, a change of CPHA will abort a transmission in progress and force the SPI system into idle state".&lt;/P&gt;&lt;P&gt;How should I implement SPI communication with these two devices in my application, or should I use different SPI ports (e.g SPI0 for DAC and SPI1 for ADC)?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A related question:&lt;/P&gt;&lt;P&gt;I developed a small application to test SPI with TLC5618:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; EnableInterrupt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET_PLL();&lt;/P&gt;&lt;P&gt;&amp;nbsp; SPI_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_send();&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works correctly. If I put SPI_init() into the loop:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; EnableInterrupt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET_PLL();&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_send();&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It does't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Sep 2014 01:38:11 GMT</pubDate>
    <dc:creator>ruiji</dc:creator>
    <dc:date>2014-09-19T01:38:11Z</dc:date>
    <item>
      <title>MC9S12DG256 SPI with multiple slaves</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330087#M10433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;MC9S12DG256 SPI with two slave devices: DAC TLC5618 and ADC AD7888.&lt;/P&gt;&lt;P&gt;They are both connected to SPI0, but they require different SPI configurations (for TLC5618 CPHA=0, for AD7888 CPHA=1).&lt;/P&gt;&lt;P&gt;I found in the MC9S12DG256 datasheet that "In master mode, a change of CPHA will abort a transmission in progress and force the SPI system into idle state".&lt;/P&gt;&lt;P&gt;How should I implement SPI communication with these two devices in my application, or should I use different SPI ports (e.g SPI0 for DAC and SPI1 for ADC)?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A related question:&lt;/P&gt;&lt;P&gt;I developed a small application to test SPI with TLC5618:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; EnableInterrupt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET_PLL();&lt;/P&gt;&lt;P&gt;&amp;nbsp; SPI_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_send();&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works correctly. If I put SPI_init() into the loop:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; EnableInterrupt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET_PLL();&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_init();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPI_send();&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It does't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 01:38:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330087#M10433</guid>
      <dc:creator>ruiji</dc:creator>
      <dc:date>2014-09-19T01:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12DG256 SPI with multiple slaves</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330088#M10434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just don't change CPHA in the middle of a data transmission and you'll be fine. The sensible solution is of course to use different SPI ports, I think you've got 3 of them on DG256?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Sep 2014 12:47:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330088#M10434</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2014-09-19T12:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12DG256 SPI with multiple slaves</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330089#M10435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui Ji,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with Daniel. There are 3x SPI on DG256. The SPI0 is on Port S (PS4-PS7) and can be routed to Port M. The SPI1 and SPI2 are on Port H (PH0-PH7) and can also be routed to Port P.&lt;/P&gt;&lt;P&gt;You should definitely use two different SPI ports in this case (if there are unused pins on Port H or Port P).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;iggi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Sep 2014 12:29:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330089#M10435</guid>
      <dc:creator>iggi</dc:creator>
      <dc:date>2014-09-23T12:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12DG256 SPI with multiple slaves</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330090#M10436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your answers.&lt;/P&gt;&lt;P&gt;I am new in my company. I did not participate in the PCB design. Last month, they gave me the board and wanted me to make it work.&lt;/P&gt;&lt;P&gt;The DAC and ADC were both connected to SPI0, and the other two SPI ports were not used.&lt;/P&gt;&lt;P&gt;I asked them why, they sayed that they just did not pay attention to the CPHA configuration.:smileyconfused:&lt;/P&gt;&lt;P&gt;So can we say the PCB was not correctly designed?&lt;/P&gt;&lt;P&gt;Now I create two tasks in my program, AnalogToDigital ( ) and DigitalToAnalog ( ), and use a mutex to protect SPI access (I'm using uC/OS II).&lt;/P&gt;&lt;P&gt;CPHA is configured before I start the transmission.&lt;/P&gt;&lt;P&gt;void AnalogToDigital ( )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #333333; font-size: 13px;"&gt;OS&lt;/SPAN&gt;&lt;SPAN style="color: #cc0000; font-size: 13px;"&gt;MutexPend&lt;/SPAN&gt;&lt;SPAN style="color: #333333; font-size: 13px;"&gt;()&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; SPI0_CR1|=0x04;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CS=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CS=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #333333; font-size: 13px;"&gt;OS&lt;/SPAN&gt;&lt;SPAN style="color: #cc0000; font-size: 13px;"&gt;MutexPost&lt;/SPAN&gt;&lt;SPAN style="color: #333333; font-size: 13px;"&gt;();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void DigitalToAnalog ( )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #333333; font-size: 13px;"&gt;OS&lt;/SPAN&gt;&lt;SPAN style="color: #cc0000; font-size: 13px;"&gt;MutexPend&lt;/SPAN&gt;&lt;SPAN style="color: #333333; font-size: 13px;"&gt;()&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; SPI0_CR1&amp;amp;=~0x04;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CS=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CS=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #333333; font-size: 13px;"&gt;OS&lt;/SPAN&gt;&lt;SPAN style="color: #cc0000; font-size: 13px;"&gt;MutexPost&lt;/SPAN&gt;&lt;SPAN style="color: #333333; font-size: 13px;"&gt;()&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;It seems to be working, but I'm worried about frequent setting/clearing to the register.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 03:07:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12DG256-SPI-with-multiple-slaves/m-p/330090#M10436</guid>
      <dc:creator>ruiji</dc:creator>
      <dc:date>2014-10-06T03:07:40Z</dc:date>
    </item>
  </channel>
</rss>

