<?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>Kinetis Software Development Kit中的主题 Re: KL25Z ADC triggering PIT with KSDK 2.0</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607558#M6275</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am also having the same problem(s).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using Processor Expert in KDS 3.2.0 starting with a&amp;nbsp;PE&amp;nbsp;project for TWR-KV31F120M, but resulting in the same symptoms.&lt;/P&gt;&lt;P&gt;I am attempting to use an accurate timing source so that I can get a regular sample rate in order to analyze data on two analog inputs simultaneously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can get the output of the Analog Compares (CMP0_Output, CMP1_Output) to produce regular conversion triggers (driven by an external source). It is the only trigger source I have been able to make work so far, apart from single trigger events using AD#_StartSingleMeasurement(). This told me the code for my analog conversion was OK. The events for&amp;nbsp;AD2_OnMeasurementComplete() and&amp;nbsp;AD1_OnMeasurementComplete() fire regularly and in step with the external signal, as well as conversions occur at the same interval, but only with the comparator outputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I attempt to move the converters over to the FTM2_match trigger source, updating the SIM component so SIM_SOPT7 becomes 0x8A8A, the converters no longer will trigger, the status remains ERR_BUSY when I query. I have an event interrupt generated for the FTM2_CNT On-match to test if the timer referenced component is working, and this event occurs as expected, and I am able to update a counter. No triggered conversion though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried using a PIT component with the same results. Interrupt fires at a regular rate, but no triggered conversion occurs. SIM_SOPT7 is correctly set (I dump it just before calling&amp;nbsp;AD#_StartLoopTriggeredMeasurement())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is becoming a very serious issue for me as I sold the customer on this project and dev environment since it should be faster to get something running than the competitor's. Here I sit unable to perform synchronized conversions. A basic function of a digital signal controller used for motor control. Everything else work great, but this is a critical issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Granted I am a bit rusty at C code, but this one is looking to be a potential errata since all the registers seem to be OK, unless I am missing some other SIM register that is somehow involved in all of this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HELP!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try to generate a stripped-down PE project to post here today that exhibits this problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Oct 2016 13:29:20 GMT</pubDate>
    <dc:creator>markwyman</dc:creator>
    <dc:date>2016-10-21T13:29:20Z</dc:date>
    <item>
      <title>KL25Z ADC triggering PIT with KSDK 2.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607556#M6273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using a custom board with KL25Z and trying to convert a single ADC input using the ADC interrupt.&lt;/P&gt;&lt;P&gt;Starting from the KSDK 2.0 ADC low power example, I have tried to convert it from using LPTMR to use PIT.&lt;/P&gt;&lt;P&gt;However, it seems that even after setting the SIM-&amp;gt;SOPT7 register, the interrupt won't trigger. I never see the toggling LED and the ADC doesn't convert.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I implement this?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;/*******************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; * Definitions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ******************************************************************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define PIT_LED_HANDLER PIT_IRQHandler&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define PIT_IRQ_ID PIT_IRQn&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;/* Get source clock for PIT driver */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define PIT_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_BusClk)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define ADC_BASE_ADDR ADC0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define ADC_CHANNEL_GROUP 0U&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define ADC_USER_CHANNEL 0U&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define ADC_IRQ_ID ADC0_IRQn&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define ADC_IRQ_HANDLER_FUNC ADC0_IRQHandler&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;/*******************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; * Variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ******************************************************************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;volatile static uint32_t adcValue = 0; /*! ADC value */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;volatile bool conversionCompleted = false; /*! Conversion is completed Flag */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;volatile bool pitIsrFlag = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;volatile static uint16_t samplesCounter = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;/*******************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; * Code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ******************************************************************************/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;void BOARD_ConfigTriggerSource(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Configure SIM for ADC hw trigger source selection */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; SIM-&amp;gt;SOPT7 |= (SIM_SOPT7_ADC0ALTTRGEN(1) | SIM_SOPT7_ADC0PRETRGSEL(0) | SIM_SOPT7_ADC0TRGSEL(0x4));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;void PIT_InitADCTriggerSource(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; // Initialise PIT0 module and enable run in debug&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; pit_config_t pitConfig =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; .enableRunInDebug = true&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; };&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Init PIT */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; PIT_Init(PIT,&amp;amp;pitConfig);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Set 62us interrupt */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; PIT_SetTimerPeriod(PIT,kPIT_Chnl_0, USEC_TO_COUNT(62U, PIT_SOURCE_CLOCK));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Start counting on channel 0 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; PIT_StartTimer(PIT, kPIT_Chnl_0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Configure SIM for ADC hw trigger source selection */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; BOARD_ConfigTriggerSource();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;static void ADC16_PauseConversion(ADC_Type *base)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adc16_channel_config_t adcChnConfig;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcChnConfig.channelNumber = 0U; /*!&amp;lt; AD0 channel */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcChnConfig.enableInterruptOnConversionCompleted = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcChnConfig.enableDifferentialConversion = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_SetChannelConfig(base, ADC_CHANNEL_GROUP, &amp;amp;adcChnConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;static void ADC16_CalibrateParams(ADC_Type *base)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adc16_config_t adcUserConfig;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adc16_channel_config_t adcChnConfig;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_GetDefaultConfig(&amp;amp;adcUserConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.resolution = kADC16_Resolution16Bit;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.enableContinuousConversion = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.clockSource = kADC16_ClockSourceAsynchronousClock;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.enableLowPower = 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_Init(base, &amp;amp;adcUserConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcChnConfig.enableInterruptOnConversionCompleted = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_SetChannelConfig(base, ADC_CHANNEL_GROUP, &amp;amp;adcChnConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Wait for the conversion to be done */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; while (!ADC16_GetChannelStatusFlags(base, ADC_CHANNEL_GROUP))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_PauseConversion(base);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;static bool ADC16_InitHardwareTrigger(ADC_Type *base)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adc16_config_t adcUserConfig;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adc16_channel_config_t adcChnConfig;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_GetDefaultConfig(&amp;amp;adcUserConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.resolution = kADC16_Resolution16Bit;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* enabled hardware trigger */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_EnableHardwareTrigger(base, true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.enableContinuousConversion = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.clockSource = kADC16_ClockSourceAsynchronousClock;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.longSampleMode = kADC16_LongSampleCycle24;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcUserConfig.enableLowPower = 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_Init(base, &amp;amp;adcUserConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcChnConfig.channelNumber = ADC_USER_CHANNEL;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcChnConfig.enableDifferentialConversion = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcChnConfig.enableInterruptOnConversionCompleted = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Configure channel 0 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_SetChannelConfig(base, ADC_CHANNEL_GROUP, &amp;amp;adcChnConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; return true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;void ADC16_IRQ_HANDLER_FUNC(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Get current ADC value */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; adcValue = ADC16_GetChannelConversionValue(ADC_BASE_ADDR, ADC_CHANNEL_GROUP);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Set conversionCompleted flag. This prevents an wrong conversion in main function */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; conversionCompleted = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; LED_BLUE_TOGGLE();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;void LEDInit(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; LED_RED_INIT(LOGIC_LED_OFF);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; LED_GREEN_INIT(LOGIC_LED_OFF);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; LED_BLUE_INIT(LOGIC_LED_OFF);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; LED_YELLOW_INIT(LOGIC_LED_OFF);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;int main(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; pit_config_t pitConfig&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;.enableRunInDebug = true&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; BOARD_InitPins();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; BOARD_BootClockRUN();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; LEDInit();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; ADC16_CalibrateParams(ADC0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; if (!ADC16_InitHardwareTrigger(ADC_BASE_ADDR))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;LED_RED_ON();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return -1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; PIT_GetDefaultConfig(&amp;amp;pitConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Init pit module */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; PIT_Init(PIT, &amp;amp;pitConfig);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Set timer period for channel 0 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; PIT_SetTimerPeriod(PIT, kPIT_Chnl_0, USEC_TO_COUNT(100U, PIT_SOURCE_CLOCK));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; PIT_StartTimer(PIT, kPIT_Chnl_0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Enable timer interrupts for channel 0 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; //PIT_EnableInterrupts(PIT, kPIT_Chnl_0, kPIT_TimerInterruptEnable);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; BOARD_ConfigTriggerSource();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Enable at the NVIC */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; EnableIRQ(ADC_IRQ_ID);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Start channel 0 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;PIT_StartTimer(PIT, kPIT_Chnl_0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for(;;) /* Infinite loop to avoid leaving the main function */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; /* Check whether occur interupt and toggle LED */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if (conversionCompleted)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LED_GREEN_ON();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2016 21:23:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607556#M6273</guid>
      <dc:creator>gustavsl</dc:creator>
      <dc:date>2016-10-04T21:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: KL25Z ADC triggering PIT with KSDK 2.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607557#M6274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" class="" data-content-finding="Community" data-userid="230895" data-username="gustavsl" href="https://community.nxp.com/people/gustavsl"&gt;Gustavo Leal&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am very sorry for the late response.&lt;/P&gt;&lt;P&gt;We will let you know as soon as possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for your patience.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Iva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2016 10:22:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607557#M6274</guid>
      <dc:creator>ivadorazinova</dc:creator>
      <dc:date>2016-10-21T10:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: KL25Z ADC triggering PIT with KSDK 2.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607558#M6275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am also having the same problem(s).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using Processor Expert in KDS 3.2.0 starting with a&amp;nbsp;PE&amp;nbsp;project for TWR-KV31F120M, but resulting in the same symptoms.&lt;/P&gt;&lt;P&gt;I am attempting to use an accurate timing source so that I can get a regular sample rate in order to analyze data on two analog inputs simultaneously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can get the output of the Analog Compares (CMP0_Output, CMP1_Output) to produce regular conversion triggers (driven by an external source). It is the only trigger source I have been able to make work so far, apart from single trigger events using AD#_StartSingleMeasurement(). This told me the code for my analog conversion was OK. The events for&amp;nbsp;AD2_OnMeasurementComplete() and&amp;nbsp;AD1_OnMeasurementComplete() fire regularly and in step with the external signal, as well as conversions occur at the same interval, but only with the comparator outputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I attempt to move the converters over to the FTM2_match trigger source, updating the SIM component so SIM_SOPT7 becomes 0x8A8A, the converters no longer will trigger, the status remains ERR_BUSY when I query. I have an event interrupt generated for the FTM2_CNT On-match to test if the timer referenced component is working, and this event occurs as expected, and I am able to update a counter. No triggered conversion though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried using a PIT component with the same results. Interrupt fires at a regular rate, but no triggered conversion occurs. SIM_SOPT7 is correctly set (I dump it just before calling&amp;nbsp;AD#_StartLoopTriggeredMeasurement())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is becoming a very serious issue for me as I sold the customer on this project and dev environment since it should be faster to get something running than the competitor's. Here I sit unable to perform synchronized conversions. A basic function of a digital signal controller used for motor control. Everything else work great, but this is a critical issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Granted I am a bit rusty at C code, but this one is looking to be a potential errata since all the registers seem to be OK, unless I am missing some other SIM register that is somehow involved in all of this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HELP!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try to generate a stripped-down PE project to post here today that exhibits this problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2016 13:29:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607558#M6275</guid>
      <dc:creator>markwyman</dc:creator>
      <dc:date>2016-10-21T13:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: KL25Z ADC triggering PIT with KSDK 2.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607559#M6276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;Hi Gustavo,&lt;/P&gt;&lt;P&gt;The adc16_low_power_frdmkl25z demo by default is using the LPTMR since it can operate in VLPS mode and wake up the system.&lt;/P&gt;&lt;P&gt;When setting up this demo to use the PIT, the following changes were needed:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Include a PIT ISR to clear its flag&lt;/LI&gt;&lt;LI&gt;Change the VLPS mode to Normal Wait so that the PIT could be used.&lt;/LI&gt;&lt;LI&gt;Add the &lt;SPAN&gt;fsl_pit.c&lt;/SPAN&gt;/h files to your "drivers" folder.&lt;/LI&gt;&lt;/UL&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached my "C" code.&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Only need to make following change to run in the default LPTMR mode or switch to use PIT.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas; COLOR: #7f0055;"&gt;#define&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas; COLOR: black;"&gt; LPTMR false&lt;SPAN style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas; COLOR: #3f7f5f;"&gt;//DES true=LPTMR (default code too), false=PIT (test code)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look for "//DES" to see all changes and comments.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2016 18:02:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607559#M6276</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2016-10-21T18:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: KL25Z ADC triggering PIT with KSDK 2.0</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607560#M6277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, in the process of creating the stripped-down project, I got the PIT timers to work (but not the FTM counters). It did lead to a discovery why I couldn't get them to work previously though, so perhaps the OP can be helped by this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had the PIT timers set up in the same way before I performed this task, but they were not&amp;nbsp;working. It appears that if I have the options set up for Number of Conversions set to something other than 1 (I had 4) when I change the trigger source, the code is not generated properly (timing set too slow on Conversion Time?) or some other type of error. I did not get to the bottom of it as I did not know what to look for. The conversion interval on the PIT timer is set to 100uS, and the single conversion time - Differential is set to &amp;lt;40uS, so there was ample time to finish a 4xconversion before the next trigger event. However, if I set the Number of conversions to 1, generate PE code, test, (works), then set back to 4, it begins to work again without changing anything between the two 4 conversions settings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So something is fishy in the PE tool that is misleading.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the OP, did you intend to have continuous conversions off? I think this should be True if you want the PIT to provide regular timing to your conversions.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #f6f6f6;"&gt;adcUserConfig.enableContinuousConversion = false;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2016 18:49:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/KL25Z-ADC-triggering-PIT-with-KSDK-2-0/m-p/607560#M6277</guid>
      <dc:creator>markwyman</dc:creator>
      <dc:date>2016-10-21T18:49:03Z</dc:date>
    </item>
  </channel>
</rss>

