<?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 TWR-K70F120M     ADC     ISSUE in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/TWR-K70F120M-ADC-ISSUE/m-p/422883#M24249</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt;I need your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem:&lt;BR /&gt;I need 4 (A,B,C,D) measures at 16 bits in differential mode.&lt;BR /&gt;I can't find any example or "Typical usage" or Application Note...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My environment:&lt;/P&gt;&lt;P&gt;TWR-K70F120M&lt;/P&gt;&lt;P&gt;KDS_3.0.0&lt;/P&gt;&lt;P&gt;KSDK_1.2.0&lt;/P&gt;&lt;P&gt;PROCESSOR EXPERT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHAT I NEED:&lt;/P&gt;&lt;P&gt;MEASURE A&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC0_DP0&amp;nbsp; ;&amp;nbsp; ADC0_DM0 )&lt;BR /&gt;MEASURE B&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC0_DP1&amp;nbsp; ;&amp;nbsp; ADC0_DM1 )&lt;/P&gt;&lt;P&gt;MEASURE C&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC1_DP0&amp;nbsp; ;&amp;nbsp; ADC1_DM0 )&lt;BR /&gt;MEASURE D&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC1_DP1&amp;nbsp; ;&amp;nbsp; ADC1_DM1 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;Daniel Abad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Aug 2015 09:52:28 GMT</pubDate>
    <dc:creator>danieljabad</dc:creator>
    <dc:date>2015-08-07T09:52:28Z</dc:date>
    <item>
      <title>TWR-K70F120M     ADC     ISSUE</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/TWR-K70F120M-ADC-ISSUE/m-p/422883#M24249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt;I need your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem:&lt;BR /&gt;I need 4 (A,B,C,D) measures at 16 bits in differential mode.&lt;BR /&gt;I can't find any example or "Typical usage" or Application Note...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My environment:&lt;/P&gt;&lt;P&gt;TWR-K70F120M&lt;/P&gt;&lt;P&gt;KDS_3.0.0&lt;/P&gt;&lt;P&gt;KSDK_1.2.0&lt;/P&gt;&lt;P&gt;PROCESSOR EXPERT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHAT I NEED:&lt;/P&gt;&lt;P&gt;MEASURE A&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC0_DP0&amp;nbsp; ;&amp;nbsp; ADC0_DM0 )&lt;BR /&gt;MEASURE B&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC0_DP1&amp;nbsp; ;&amp;nbsp; ADC0_DM1 )&lt;/P&gt;&lt;P&gt;MEASURE C&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC1_DP0&amp;nbsp; ;&amp;nbsp; ADC1_DM0 )&lt;BR /&gt;MEASURE D&amp;nbsp; &amp;lt;--&amp;nbsp; ( ADC1_DP1&amp;nbsp; ;&amp;nbsp; ADC1_DM1 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;Daniel Abad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Aug 2015 09:52:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/TWR-K70F120M-ADC-ISSUE/m-p/422883#M24249</guid>
      <dc:creator>danieljabad</dc:creator>
      <dc:date>2015-08-07T09:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: TWR-K70F120M     ADC     ISSUE</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/TWR-K70F120M-ADC-ISSUE/m-p/422884#M24250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis K70 is not supported in KSDK 1.2.0 so you need to create a new project that uses Processor Expert Support.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, you need to configure 2 ADC modules (ADC0 and ADC1, each one using 2 channels) to be triggered by Programmable Delay Module (PDB). PDB module will allow you to trigger every ADC channel with specific time intervals.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ADC:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; We configure every ADC module to use Single conversion mode, 16-bit format and HW Trigger.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="ADC Configuration.jpg"&gt;&lt;IMG alt="ADC Configuration.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52511iEDD46719777DC880/image-size/large?v=v2&amp;amp;px=999" title="ADC Configuration.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Then, we configure pins used for Channel 0 and Channel 1. After this, we configure trigger sources for Trigger A and B (Select PDB0_CH0_TriggerA and PDB0_CH0_TriggerB respectively)&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Trigger A and B selection.jpg"&gt;&lt;IMG alt="Trigger A and B selection.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52541iC6FE4A5805F8620D/image-size/large?v=v2&amp;amp;px=999" title="Trigger A and B selection.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; We will manage results using interrupt mode, so ensure to enable interrupt for every ADC module in both conversion complete (A and B):&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="ADC Interrupt configuration.jpg"&gt;&lt;IMG alt="ADC Interrupt configuration.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52619i04EC6C6DB408F375/image-size/large?v=v2&amp;amp;px=999" title="ADC Interrupt configuration.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Finally, we configure ADC part triggered by trigger A and B as follows:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="ADC Initialization.jpg"&gt;&lt;IMG alt="ADC Initialization.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52684iCEE12F5BAE62544F/image-size/large?v=v2&amp;amp;px=999" title="ADC Initialization.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ADC configuration the same for both modules (obviously, selecting corresponding channels to use ADCx_DPn and ADCx_DMn). Now it is time to configure PDB component.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;PDB:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;PDB is a timer that generates trigger pulses to peripherals such as ADC, DAC and CMP. In this case, we will use 4 triggers.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="PDB Settings.jpg"&gt;&lt;IMG alt="PDB Settings.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52761i3C32C7DB211E174B/image-size/large?v=v2&amp;amp;px=999" title="PDB Settings.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;In this configuration, we select the PDB source clock (Derived from Bus clock) This clock is calculated as (Bus Clock / (Divider * Prescaler)).&lt;/P&gt;&lt;P&gt;Once frequency is calculated, we set the value in which the timer will be reset, in this case, as source clock is 15MHz, we select modulus value to be 15000 to have 1 ms period.&lt;/P&gt;&lt;P&gt;(1 / 15MHz = 66nS; 15000 * 66nS = 1ms)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We select the continuous mode (once the input trigger is received, timer will count until it reaches modulus value, then, it is reset and start counting again.)&lt;/P&gt;&lt;P&gt;In next tab (Channels) we configure Channel 0 trigger and Channel 1 trigger to generate triggers at 250 us, 500us, 750us and 1ms:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="PDB Channels.jpg"&gt;&lt;IMG alt="PDB Channels.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52762i59BC428F44830D05/image-size/large?v=v2&amp;amp;px=999" title="PDB Channels.jpg" /&gt;&lt;/SPAN&gt;Then, in Pins/Signals tab, we can select up to 16 different input trigger sources (the trigger to start counting), in this case, we select software trigger.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Software Trigger for PDB.jpg"&gt;&lt;IMG alt="Software Trigger for PDB.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52827i4B8C9E1111D307FC/image-size/large?v=v2&amp;amp;px=999" title="Software Trigger for PDB.jpg" /&gt;&lt;/SPAN&gt;Now, that's it.&lt;/P&gt;&lt;P&gt;We have configured both peripherals in order to be read one ADC channel every 250 us (so every 1 ms we will read these 4 channles).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, generate PE code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In main.c file, we add header files for ADC and PDB:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14393117345853118 jive_text_macro" data-renderedposition="2975.183349609375_8_1232_48" jivemacro_uid="_14393117345853118"&gt;&lt;P&gt;#include "PDB_PDD.h"&lt;/P&gt;&lt;P&gt;#include "ADC_PDD.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And add Interrupt Service Routines for ADC0 and ADC1:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14393117730104383" data-renderedposition="3065.183349609375_8_1232_320" jivemacro_uid="_14393117730104383"&gt;&lt;P&gt;void ADC0_ISR () {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ADC_PDD_GetConversionCompleteFlag(ADC0_DEVICE,0)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC0_A_conv = ADC_PDD_GetResultValueRaw(ADC0_DEVICE,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ADC_PDD_GetConversionCompleteFlag(ADC0_DEVICE,1)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC0_B_conv = ADC_PDD_ReadDataResultReg(ADC0_DEVICE,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void ADC1_ISR () {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ADC_PDD_GetConversionCompleteFlag(ADC1_DEVICE,0)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC1_A_conv = ADC_PDD_GetResultValueRaw(ADC1_DEVICE,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ADC_PDD_GetConversionCompleteFlag(ADC1_DEVICE,1)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC1_B_conv = ADC_PDD_ReadDataResultReg(ADC1_DEVICE,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;ADC0_A_conv, ADC0_B_conv, ADC1_A_conv and ADC1_B_conv will save the converted value for each channel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, we only need to trigger PDB channel in order to start conversions on ADC. Like we select PDB software trigger, we call next function:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14393120081815999 jive_macro_code jive_text_macro" data-renderedposition="3448.183349609375_8_1232_160" jivemacro_uid="_14393120081815999"&gt;&lt;P&gt;/* Write your local variable definition here */&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/&lt;/P&gt;&lt;P&gt;&amp;nbsp; PE_low_level_init();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*** End of Processor Expert internal initialization.&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;&amp;nbsp;&amp;nbsp; ***/&lt;/P&gt;&lt;P&gt;&amp;nbsp; PDB_PDD_SoftwareTrigger(PDB0_DEVICE);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for (;;) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attach this project in which I add DAC support to convert this digital value into an analog value again, and verify that every channel (with constant analog value) is sample every 250us:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Sampling every 1 ms.jpg"&gt;&lt;IMG alt="Sampling every 1 ms.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/52850i8F2F38905ECB9C29/image-size/large?v=v2&amp;amp;px=999" title="Sampling every 1 ms.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;As you can see on previous image, 4 channels are sample every 1 ms. If you desired to change this value, it is necessary to modify PDB's period and Channels delays.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this can help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isaac&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:19:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/TWR-K70F120M-ADC-ISSUE/m-p/422884#M24250</guid>
      <dc:creator>isaacavila</dc:creator>
      <dc:date>2020-11-02T13:19:10Z</dc:date>
    </item>
  </channel>
</rss>

