<?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: Question regarding ADC Example project in MPC5748G in MPC5xxx</title>
    <link>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056961#M15862</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chapter 32.6.12 says " sample time duration is controlled by the INPSAMP[7:0] filed of conversion timing register ADC_CTRx(x=0..2) for different types of channels...The value in the register represents units of cycle of the AD_clk."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How does it express in the code exactly?(when ADC clock = bus clock(80MHz))&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you provide an example? (e.x. ADC sampling rate =10KHz)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_464.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/105049iBBB0EED464AE2B41/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_464.png" alt="pastedImage_464.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Junyi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 May 2020 18:47:12 GMT</pubDate>
    <dc:creator>jzhang1</dc:creator>
    <dc:date>2020-05-22T18:47:12Z</dc:date>
    <item>
      <title>Question regarding ADC Example project in MPC5748G</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056959#M15860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been running the ADC example code in S32DS, which converts the ADC result to illuminate the LED light on the MPC7548G board. The example code contains ADC1_Calibration(), ADC_Init(), ADC1_Read_Chan() and &lt;SPAN&gt;update_LEDs()&lt;/SPAN&gt;, which works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) My question is how to set the ADC sampling rate? I want to implement the 'oversampling' method into my project but couldn't find where to set. Let's say I want to manually set the ADC sampling rate at 20KHz, and the incoming analog signal is 10KHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Also the example project only reads and stores the latest value of the ADC conversion result, how to store and monitor the entire ADC conversion result(continuously)? Is there a way to monitor the ADC conversion result in real-time or store it somewhere so I can check it later?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reference Codes from the Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void ADC1_Init(void) { /* Initialize ADC1 module &amp;amp; start normal scan mode */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.PWDN = 1; /* Power down for starting module initialization */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.OWREN = 1; /* Enable overwriting older conversion results */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.MODE = 1; /* Scan mode (1) used instead of one shot mode */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.ADCLKSEL = 1; /* ADC clock = FS80 bus clock (80 MHz here) */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.PWDN = 0; /* ADC_1 ready to receive conversation triggers */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.NSTART = 1; /* Initiate trigger for normal scan */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void ADC1_Read_Chan (void) { /* Read conversion results */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;Result= ADC_1.CDR[8].B.CDATA; /* Read channel 9 conversion result data */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ResultInMv = (uint16_t) (ADC_VREF*Result/0xFFF); /* Conversion in mV */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void ADC1_Calibration(void) { /* Calibrate to compensate for variations. Steps below are from reference manual */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;uint32_t __attribute__ ((unused)) ADC1_Calibration_Failed = 1; /* Calibration has not passed yet */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.PWDN = 1; /* Power down for starting calibration process */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.ADCLKSEL = 0; /* ADC clock = bus clock/2 (80/2 MHz FS80) */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;/* Note: Calibration requires it to be set at max 40MHz for best results */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.CALBISTREG.B.TEST_EN = 1; /* Enable calibration test */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC_1.MCR.B.PWDN = 0; /* Power back up for calibration test to start */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;while(ADC_1.CALBISTREG.B.C_T_BUSY); /* Wait for calibration to finish */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if(ADC_1.MSR.B.CALIBRTD) { /* If calibration ran successfully */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ADC1_Calibration_Failed = 0; /* Calibration was successful */&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ADC1_Calibration_Failed = 1; /* Calibration was not successful */&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void update_LEDs(void) { /* Update LEDs with scaled channel 9 Result */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PA4].R = ~(Result &amp;amp; 0x0800)&amp;gt;&amp;gt;11;/* LED1: scaled channel 9 LSB */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PA0].R = ~(Result &amp;amp; 0x0400)&amp;gt;&amp;gt;10;/* LED2 */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PJ4].R = ~(Result &amp;amp; 0x0200)&amp;gt;&amp;gt;9; /* LED3 */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PH5].R = ~(Result &amp;amp; 0x0100)&amp;gt;&amp;gt;8; /* LED4 */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PC4].R = ~(Result &amp;amp; 0x0080)&amp;gt;&amp;gt;7; /* LED5 */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PH13].R = ~(Result &amp;amp; 0x0040)&amp;gt;&amp;gt;6;/* LED6 */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PA7].R = ~(Result &amp;amp; 0x0020)&amp;gt;&amp;gt;5; /* LED7 */&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIUL2.GPDO[PA10].R = ~(Result &amp;amp; 0x0010)&amp;gt;&amp;gt;4; /* LED8: scaled channel 9 MSB */&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2020 15:34:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056959#M15860</guid>
      <dc:creator>jzhang1</dc:creator>
      <dc:date>2020-05-21T15:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding ADC Example project in MPC5748G</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056960#M15861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) sampling rate is set by programming CTR0 register. See chapter&amp;nbsp;32.6.12 Conversion time of the RM for more info.&lt;/P&gt;&lt;P&gt;2) ADC is set to scan mode and it reads converted data once conversion is finished. You can store the result into some array, if you want to do some post-processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR, Petr&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2020 07:29:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056960#M15861</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2020-05-22T07:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding ADC Example project in MPC5748G</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056961#M15862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chapter 32.6.12 says " sample time duration is controlled by the INPSAMP[7:0] filed of conversion timing register ADC_CTRx(x=0..2) for different types of channels...The value in the register represents units of cycle of the AD_clk."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How does it express in the code exactly?(when ADC clock = bus clock(80MHz))&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you provide an example? (e.x. ADC sampling rate =10KHz)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_464.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/105049iBBB0EED464AE2B41/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_464.png" alt="pastedImage_464.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Junyi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2020 18:47:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056961#M15862</guid>
      <dc:creator>jzhang1</dc:creator>
      <dc:date>2020-05-22T18:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Question regarding ADC Example project in MPC5748G</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056962#M15863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for&amp;nbsp;Subsequent/continuous conversion you have&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1/sample_rate = ADC_clk/(INPSAMP+(13+1)*4+2) =&amp;gt; INPSAMP = ADC_clk/sample_rate - 58&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INPSAMP is 255 max so you cannot get 10kHz sample rate for ADC_clk you have (80MHz/2), unless you lower bus clock which is not desired. So keep sample rate eg typical 1MHz and trigger ADC with your rate. Either use injected or BCTU triggered conversion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR, Petr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2020 08:47:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Question-regarding-ADC-Example-project-in-MPC5748G/m-p/1056962#M15863</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2020-05-25T08:47:42Z</dc:date>
    </item>
  </channel>
</rss>

