<?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 Re: MC9S08GT60A - SPI / GPIO conflict? in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60A-SPI-GPIO-conflict/m-p/143071#M6476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&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;I am not familiar with the AD7799, but here are a few observations -&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;I notice you have a macro to enable ChipSelect, but not to disable it.&amp;nbsp; What are the chip select requirements of&amp;nbsp;the AD7799?&amp;nbsp; I might expect that this should be released after each reading.&amp;nbsp;&amp;nbsp;While monitoring SDO as a "ready" signal, does chip select need to be enabled?&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;To monitor the MOSI pin while a SPI transfer is &lt;U&gt;not&lt;/U&gt; occurring, this pin would need to revert to GPIO.&amp;nbsp; Therefore the SPI module will need to be disabled during the monitoring process, and re-enabled just prior to commecing the read process.&amp;nbsp; This is because the SPI peripheral function will over-ride the GPIO facility.&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;Are your CPHA and CPOL settings compatible with the AD7799?&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;Is there a particular reason for using continuous conversion mode for the ADC?&amp;nbsp; An alternative approach&amp;nbsp;could be to initiate the next&amp;nbsp;conversion following the read of the previous conversion.&amp;nbsp; KBI interrupt on falling SDO might be used to process each reading.&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>Wed, 15 Aug 2007 09:58:14 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2007-08-15T09:58:14Z</dc:date>
    <item>
      <title>MC9S08GT60A - SPI / GPIO conflict?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60A-SPI-GPIO-conflict/m-p/143070#M6475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I have a MC9S08GT60A interfaced to an ADC (AD7799) using&amp;nbsp;SPI. The ADC is configured to continuously convert values and drop its SDO low whenever values are ready to be read.&amp;nbsp; SDO goes high while it is in the process of converting; during this time data cannot be read (SDO is high at an approx. 5% duty cycle).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The test program I set up is supposed to enable continuous conversion mode, then wait for SDO to assert low and then clock out the data. The&amp;nbsp;code is below.&amp;nbsp;The code, however, does&amp;nbsp;not yield&amp;nbsp;the proper output.&amp;nbsp;&amp;nbsp;I&amp;nbsp;am having&amp;nbsp;very hard time figuring out why. When this code is executed,&amp;nbsp;the logic analyzer shows that SDO (MISO on the MCU) is inverted&amp;nbsp;with the pin&amp;nbsp;going high when data is ready and low while converting. Also strange is that SPI read occurs right after SDO goes from low to high so when I sample the data I get 0xFFFFFF, which is very wrong.&amp;nbsp;If&amp;nbsp;I run the program and simply comment out &lt;SPAN style="font-family: 'Courier New';"&gt;ReadSPI24Bits(&amp;amp;data)&lt;/SPAN&gt;, SDO&amp;nbsp;(MISO on the MCU) returns to normal. It is only when I&amp;nbsp;sample that SDO becomes inverted.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I break in the sampling loop, PTED=0x10, PTEPE=0x00, PTESE=0x00, and PTEDD=0x37.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Initially, I thought that since I was trying to use the MISO on the MCU as an input while the SPI module was enabled I could be causing the problem. So I tied pin B2 to MISO and queried B2 to avoid that but still ran into the same inversion problem. So how do I get this silly thing to work?&amp;nbsp;Sorry about the lengthy explaination but I wanted to make sure I covered all the bases. Thank you in advance for any help in solving this problem.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#define SPIS_DummyRead&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {char dummy=SPIS}#define SPIDummyWrite&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {SPID=0x00}#define WaitSPIRxBufferFull&amp;nbsp;&amp;nbsp; {while (!(SPIS &amp;amp; 0x80));}#define ChipSelect&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {PTED &amp;amp;= ~0x04;}// functions to read 8 bits of data through SPIvoid ReadSPI(uint8_t* byteRead) {&amp;nbsp;&amp;nbsp; SPIS_DummyRead;&amp;nbsp;&amp;nbsp; SPIDummyWrite;&amp;nbsp;&amp;nbsp; WaitSPIRxBufferFull;&amp;nbsp;&amp;nbsp; *byteRead = SPID;}// functions to read 24 bits of data through SPIvoid ReadSPI24Bits(uint32_t* byteRead) {&amp;nbsp;&amp;nbsp; uint8_t data1, data2, data3;&amp;nbsp;&amp;nbsp; uint32_t result;&amp;nbsp;&amp;nbsp; ReadSPI(&amp;amp;data1);&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;&amp;nbsp; // Read 24 bits of data&amp;nbsp;&amp;nbsp; Wait_6_Clks();&amp;nbsp;&amp;nbsp; ReadSPI(&amp;amp;data2);&amp;nbsp;&amp;nbsp; Wait_6_Clks();&amp;nbsp;&amp;nbsp; ReadSPI(&amp;amp;data3);&amp;nbsp;&amp;nbsp; result = data1;&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;&amp;nbsp;&amp;nbsp; // combine data into one variable&amp;nbsp;&amp;nbsp; result = result &amp;lt;&amp;lt; 8;&amp;nbsp;&amp;nbsp; result = result + data2;&amp;nbsp;&amp;nbsp; result = result &amp;lt;&amp;lt; 8;&amp;nbsp;&amp;nbsp; result = result + data3;&amp;nbsp;&amp;nbsp; *byteRead = result;}void collectData(void) {&amp;nbsp;&amp;nbsp; uint32_t data;&amp;nbsp;&amp;nbsp; SPIC1 = 0x5C;&amp;nbsp;&amp;nbsp; SPIC2 = 0x00;&amp;nbsp;&amp;nbsp; ChipSelect;&amp;nbsp;&amp;nbsp; // omitted code to set up ADC, I know that is ok&amp;nbsp;&amp;nbsp; // after ADC is setup, get data&amp;nbsp;&amp;nbsp; while (1) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // sample only if pin B2 is low&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!(PTBD &amp;amp; 0x04)) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ReadSPI24Bits(&amp;amp;data);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; }}&lt;/PRE&gt;Added p/n to subject.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by NLFSJ on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-08-14&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;09:43 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:43:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60A-SPI-GPIO-conflict/m-p/143070#M6475</guid>
      <dc:creator>nareec</dc:creator>
      <dc:date>2020-10-29T08:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60A - SPI / GPIO conflict?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60A-SPI-GPIO-conflict/m-p/143071#M6476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&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;I am not familiar with the AD7799, but here are a few observations -&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;I notice you have a macro to enable ChipSelect, but not to disable it.&amp;nbsp; What are the chip select requirements of&amp;nbsp;the AD7799?&amp;nbsp; I might expect that this should be released after each reading.&amp;nbsp;&amp;nbsp;While monitoring SDO as a "ready" signal, does chip select need to be enabled?&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;To monitor the MOSI pin while a SPI transfer is &lt;U&gt;not&lt;/U&gt; occurring, this pin would need to revert to GPIO.&amp;nbsp; Therefore the SPI module will need to be disabled during the monitoring process, and re-enabled just prior to commecing the read process.&amp;nbsp; This is because the SPI peripheral function will over-ride the GPIO facility.&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;Are your CPHA and CPOL settings compatible with the AD7799?&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;Is there a particular reason for using continuous conversion mode for the ADC?&amp;nbsp; An alternative approach&amp;nbsp;could be to initiate the next&amp;nbsp;conversion following the read of the previous conversion.&amp;nbsp; KBI interrupt on falling SDO might be used to process each reading.&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>Wed, 15 Aug 2007 09:58:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60A-SPI-GPIO-conflict/m-p/143071#M6476</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-08-15T09:58:14Z</dc:date>
    </item>
  </channel>
</rss>

