<?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: LPC804 ADC threshold compare interrupt hangs the device in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1459916#M48815</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/26034"&gt;@xiangjun_rong&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I finally managed to make it work by setting irq code inside "exterrn C" area, but it kept still hanging when system started outside thresholds range. There was no problem if system was turned on inside thresholds range, adc irq was working fine in both crossing and out_of_level modes, but when Voltage was out of low-high thresholds range when turning system on, system kept hanging.&lt;BR /&gt;&lt;BR /&gt;My project is not so critical to need using adc interrupt but it was a smart option, especially the out_of_range mode, as long as threshold crossing mode only uses low threshold for comparing.&lt;/P&gt;&lt;P&gt;I finally handled it by polling adc measurement via MRT timer interrupt.&lt;/P&gt;&lt;P&gt;Thank you anyway.&lt;/P&gt;&lt;P&gt;Kind regards!&lt;/P&gt;</description>
    <pubDate>Wed, 18 May 2022 09:55:24 GMT</pubDate>
    <dc:creator>Hector_Jimenez</dc:creator>
    <dc:date>2022-05-18T09:55:24Z</dc:date>
    <item>
      <title>LPC804 ADC threshold compare interrupt hangs the device</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1456231#M48731</link>
      <description>&lt;P&gt;Hello!&lt;BR /&gt;&lt;BR /&gt;I'm trying to use LPC804 ADC threshold compare interrupt to do some certain things when defined threshold are exceeded, but whenever I set the voltage upper or lower than these thresholds, my system hangs up.&lt;BR /&gt;&lt;BR /&gt;I'm using SDK_2.x_LPC804 (2.11.0 version) to create ADC peripheral and the following code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;static void ADC_init(void) {
  /* Initialize ADC peripheral */
  ADC_Init(ADC_PERIPHERAL, &amp;amp;ADCconfigStruct);
  /* Configure the conversion sequence A */
  ADC_SetConvSeqAConfig(ADC_PERIPHERAL, &amp;amp;ADCConvSeqAConfigStruct);
  /* Enable the conversion sequence A */
  ADC_EnableConvSeqA(ADC_PERIPHERAL, true);
  /* Initialize 0. pair of threshold setting */
  ADC_SetThresholdPair0(ADC_PERIPHERAL, 1100U, 1500U);
  /* Assign threshold setting pairs to channels */
  ADC_SetChannelWithThresholdPair0(ADC_PERIPHERAL, 512U);
  /* Configure threshold compare interrupt on channel 9 */
  ADC_EnableThresholdCompareInterrupt(ADC_PERIPHERAL, 9U, kADC_ThresholdInterruptOnOutside);
  /* Enable interrupt ADC_THCMP_IRQn request in the NVIC. */
  EnableIRQ(ADC_ADC_THCMP_IRQN);
}
...
/* ADC_THCMP_IRQn interrupt handler */
void ADC_ADC_THCMP_IRQHANDLER(void) {
  /* Get status flags */
  if (kADC_ThresholdCompareInterruptFlag == (kADC_ThresholdCompareInterruptFlag &amp;amp; ADC_GetStatusFlags(ADC_PERIPHERAL)))
  {
  	/* Place your interrupt code here */
	// Get ADC level of interrupt (LOW/HIGH)
	adc_result_info_t info;
	ADC_GetChannelConversionResult(ADC_PERIPHERAL, 9, &amp;amp;info);
	if (info.thresholdCorssingStatus == kADC_ThresholdCrossingDownward) {
		// LOW THRESHOLD Do something
               lowThresFunc(); //dummy function
	} else if (info.thresholdCorssingStatus == kADC_ThresholdCrossingUpward) {
		// HIGH THRESHOLD Do other thing
               highThresFunc(); //dummy function
	}

  	/* Clear status flags */
  	ADC_ClearStatusFlags(ADC_PERIPHERAL, kADC_ThresholdCompareInterruptFlag);
  }

  /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F
     Store immediate overlapping exception return operation might vector to incorrect interrupt. */
  #if defined __CORTEX_M &amp;amp;&amp;amp; (__CORTEX_M == 4U)
    __DSB();
  #endif
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 08:23:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1456231#M48731</guid>
      <dc:creator>Hector_Jimenez</dc:creator>
      <dc:date>2022-05-11T08:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 ADC threshold compare interrupt hangs the device</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1457122#M48746</link>
      <description>Hi,
I suppose that you use burst mode, only when the analog voltage exceeds the high threshold can the ISR is entered and sample is acquired.
Once the analog voltage is above the upper threshold voltage, you set the ADC_EnableThresholdCompareInterrupt(ADC_PERIPHERAL, 9U, kADC_ThresholdInterruptOnOutside); mode, and ADC runs in burst mode, the void ADC_ADC_THCMP_IRQHANDLER(void) is entered for each ADC  conversion, the core is overloaded, so it seems that the chip hangs on.
I suggest you use ADC_EnableThresholdCompareInterrupt(ADC_PERIPHERAL, 9U, kADC_ThresholdInterruptOnCrossing);  so that the ADC_ADC_THCMP_IRQHANDLER(void) is entered only once.
It is only my guess, pls check if it is your case. If you use burst mode, I suggest you use software triggering mode.
BR
XiangJun Rong</description>
      <pubDate>Thu, 12 May 2022 09:17:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1457122#M48746</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2022-05-12T09:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 ADC threshold compare interrupt hangs the device</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1458733#M48773</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/26034"&gt;@xiangjun_rong&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;If happens the same using&amp;nbsp;&lt;SPAN&gt;ADC_EnableThresholdCompareInterrupt(ADC_PERIPHERAL, 9U, kADC_ThresholdInterruptOnCrossing) as you suggested. It was my first attemp as it can be seen in IRQ handler when comparing to&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;thresholdCorssingStatus &lt;/PRE&gt;&lt;P&gt;I'm using software trigger to start the sequence.&lt;/P&gt;&lt;P&gt;Any other ideas?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 15:21:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1458733#M48773</guid>
      <dc:creator>Hector_Jimenez</dc:creator>
      <dc:date>2022-05-16T15:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 ADC threshold compare interrupt hangs the device</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1459097#M48787</link>
      <description>Hi,
At the time being, what your problem is that the ADC mode mode triggers  ADC conversion too frequently, which leads to the fact that the cpu has not enough time to handle the ISR.
I do not suggest you use burst mode, but you can use the CTimer to hardware trigger ADC so that you can control the sampling frequency, in burst mode, you can not control the ADC sampling frequency.
For your application, it appears that you are only interested in the analog signal which is out of ADC compare range, you do not need to read the ADC sample, you only need to handle the ADC compare interrupt ISR.
It appears that you can use the CMP_OUT signal to trigger ADC, pls check yourself.
For ADC hardware trigger source, pls refer to Table 271. ADC hardware trigger inputs in UM11065.pdf
Hope it can help you
BR
XiangJun Rong</description>
      <pubDate>Tue, 17 May 2022 07:06:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1459097#M48787</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2022-05-17T07:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 ADC threshold compare interrupt hangs the device</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1459098#M48788</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/26034"&gt;@xiangjun_rong&lt;/a&gt;&amp;nbsp;. I'll check it out and I will let you know the results.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 07:09:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1459098#M48788</guid>
      <dc:creator>Hector_Jimenez</dc:creator>
      <dc:date>2022-05-17T07:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 ADC threshold compare interrupt hangs the device</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1459916#M48815</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/26034"&gt;@xiangjun_rong&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I finally managed to make it work by setting irq code inside "exterrn C" area, but it kept still hanging when system started outside thresholds range. There was no problem if system was turned on inside thresholds range, adc irq was working fine in both crossing and out_of_level modes, but when Voltage was out of low-high thresholds range when turning system on, system kept hanging.&lt;BR /&gt;&lt;BR /&gt;My project is not so critical to need using adc interrupt but it was a smart option, especially the out_of_range mode, as long as threshold crossing mode only uses low threshold for comparing.&lt;/P&gt;&lt;P&gt;I finally handled it by polling adc measurement via MRT timer interrupt.&lt;/P&gt;&lt;P&gt;Thank you anyway.&lt;/P&gt;&lt;P&gt;Kind regards!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 09:55:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-ADC-threshold-compare-interrupt-hangs-the-device/m-p/1459916#M48815</guid>
      <dc:creator>Hector_Jimenez</dc:creator>
      <dc:date>2022-05-18T09:55:24Z</dc:date>
    </item>
  </channel>
</rss>

