<?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 iMXRT1010 crashes when enabling interrupt in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/iMXRT1010-crashes-when-enabling-interrupt/m-p/1771539#M217104</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;My setup used when having the problems:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I am using the EVK for iMXRT1010, (PCB: revA, sch: Rev C)&lt;/LI&gt;&lt;LI&gt;MCUXpresso IDE v11.8.0 [Build 1165] [2023-07-26] for windows&lt;/LI&gt;&lt;LI&gt;a FreeRTOS based application although the problems occurs way before using any of its features&lt;/LI&gt;&lt;LI&gt;Failing code is autogenerated (peripherals.c)&lt;/LI&gt;&lt;LI&gt;Externally, except board defaults, I have active an LPUART1 and a GPIO pin set to capture a GPT value via in interrupt.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I am running a code that enables GPIO1 interrupts as shown below.&lt;/P&gt;&lt;P&gt;The problem occurs when the code gets to&amp;nbsp;&lt;EM&gt;BOARD_InitBootPeripherals();&lt;/EM&gt; with the call hierarchy:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;BOARD_InitBootPeripherals(); &lt;/EM&gt;&lt;STRONG&gt;in main.c&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;BOARD_InitPeripherals();&lt;/EM&gt; &lt;STRONG&gt;in peripherals.c&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;GPIO1_init(); &lt;/EM&gt;&lt;STRONG&gt;in peripherals.c&lt;/STRONG&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;EnableIRQ(GPIO1_GPIO_COMB_16_31_IRQN); &lt;/EM&gt;&lt;STRONG&gt;fsl_common_arm.h&lt;/STRONG&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;NVIC_EnableIRQ(interrupt); &lt;/EM&gt;&lt;STRONG&gt;in fsl_common_arm.h&lt;BR /&gt;&lt;/STRONG&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;NVIC_EnableIRQ(interrupt); &amp;lt;-&amp;gt; __NVIC_EnableIRQ &lt;/EM&gt;&lt;STRONG&gt;in core_cm7.h&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;NVIC-&amp;gt;ISER[(((uint32_t)IRQn) &amp;gt;&amp;gt; 5UL)] = (uint32_t)(1UL &amp;lt;&amp;lt; (((uint32_t)IRQn) &amp;amp; 0x1FUL)); &lt;/EM&gt;&lt;STRONG&gt;in core_cm7.h &lt;FONT color="#FF0000"&gt;This is the instruction where all crashes&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The behaviour is as follows:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;communication with the board crushes&lt;/LI&gt;&lt;LI&gt;the board does not boot anymore and I need to do a board recover, but wait:&lt;/LI&gt;&lt;LI&gt;what's worse it that this is chaotic: sometimes (the same) code works, sometimes a reset is enough to recover the board but most of the times I need to recover the board by loading a blinky() firmware via serial download to recover the board&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I tried this on 2 EVKs, 3 desktop computers and 3 IDE revisions, all ended up with the same behaviour.&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde" size="5" color="#0000FF"&gt;&lt;STRONG&gt;So, what am I doing wrong or what am I missing???&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;application entry point:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;int main(void) {
    /* Init board hardware. */
    BOARD_ConfigMPU();
    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitBootPeripherals();//this is the entry to the rabbit hole
// suppressed code lines
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sample code from autogenerated: peripherals.c&lt;/STRONG&gt;. Last line is where the rabbit hole leads.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;static void GPIO1_init(void) {
/* Make sure, the clock gate for GPIO1 is enabled (e. g. in pin_mux.c) */
/* Enable interrupt GPIO1_Combined_0_15_IRQn request in the NVIC. */
EnableIRQ(GPIO1_GPIO_COMB_0_15_IRQN);
/* Enable interrupt GPIO1_Combined_16_31_IRQn request in the NVIC. */
EnableIRQ(GPIO1_GPIO_COMB_16_31_IRQN);
}&lt;/LI-CODE&gt;&lt;P&gt;I can share the full code if needed for debug.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2023 12:46:09 GMT</pubDate>
    <dc:creator>youngSheldon</dc:creator>
    <dc:date>2023-12-08T12:46:09Z</dc:date>
    <item>
      <title>iMXRT1010 crashes when enabling interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMXRT1010-crashes-when-enabling-interrupt/m-p/1771539#M217104</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;My setup used when having the problems:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I am using the EVK for iMXRT1010, (PCB: revA, sch: Rev C)&lt;/LI&gt;&lt;LI&gt;MCUXpresso IDE v11.8.0 [Build 1165] [2023-07-26] for windows&lt;/LI&gt;&lt;LI&gt;a FreeRTOS based application although the problems occurs way before using any of its features&lt;/LI&gt;&lt;LI&gt;Failing code is autogenerated (peripherals.c)&lt;/LI&gt;&lt;LI&gt;Externally, except board defaults, I have active an LPUART1 and a GPIO pin set to capture a GPT value via in interrupt.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I am running a code that enables GPIO1 interrupts as shown below.&lt;/P&gt;&lt;P&gt;The problem occurs when the code gets to&amp;nbsp;&lt;EM&gt;BOARD_InitBootPeripherals();&lt;/EM&gt; with the call hierarchy:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;BOARD_InitBootPeripherals(); &lt;/EM&gt;&lt;STRONG&gt;in main.c&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;BOARD_InitPeripherals();&lt;/EM&gt; &lt;STRONG&gt;in peripherals.c&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;GPIO1_init(); &lt;/EM&gt;&lt;STRONG&gt;in peripherals.c&lt;/STRONG&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;EnableIRQ(GPIO1_GPIO_COMB_16_31_IRQN); &lt;/EM&gt;&lt;STRONG&gt;fsl_common_arm.h&lt;/STRONG&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;NVIC_EnableIRQ(interrupt); &lt;/EM&gt;&lt;STRONG&gt;in fsl_common_arm.h&lt;BR /&gt;&lt;/STRONG&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;NVIC_EnableIRQ(interrupt); &amp;lt;-&amp;gt; __NVIC_EnableIRQ &lt;/EM&gt;&lt;STRONG&gt;in core_cm7.h&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;NVIC-&amp;gt;ISER[(((uint32_t)IRQn) &amp;gt;&amp;gt; 5UL)] = (uint32_t)(1UL &amp;lt;&amp;lt; (((uint32_t)IRQn) &amp;amp; 0x1FUL)); &lt;/EM&gt;&lt;STRONG&gt;in core_cm7.h &lt;FONT color="#FF0000"&gt;This is the instruction where all crashes&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The behaviour is as follows:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;communication with the board crushes&lt;/LI&gt;&lt;LI&gt;the board does not boot anymore and I need to do a board recover, but wait:&lt;/LI&gt;&lt;LI&gt;what's worse it that this is chaotic: sometimes (the same) code works, sometimes a reset is enough to recover the board but most of the times I need to recover the board by loading a blinky() firmware via serial download to recover the board&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I tried this on 2 EVKs, 3 desktop computers and 3 IDE revisions, all ended up with the same behaviour.&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde" size="5" color="#0000FF"&gt;&lt;STRONG&gt;So, what am I doing wrong or what am I missing???&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;application entry point:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;int main(void) {
    /* Init board hardware. */
    BOARD_ConfigMPU();
    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitBootPeripherals();//this is the entry to the rabbit hole
// suppressed code lines
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sample code from autogenerated: peripherals.c&lt;/STRONG&gt;. Last line is where the rabbit hole leads.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;static void GPIO1_init(void) {
/* Make sure, the clock gate for GPIO1 is enabled (e. g. in pin_mux.c) */
/* Enable interrupt GPIO1_Combined_0_15_IRQn request in the NVIC. */
EnableIRQ(GPIO1_GPIO_COMB_0_15_IRQN);
/* Enable interrupt GPIO1_Combined_16_31_IRQn request in the NVIC. */
EnableIRQ(GPIO1_GPIO_COMB_16_31_IRQN);
}&lt;/LI-CODE&gt;&lt;P&gt;I can share the full code if needed for debug.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 12:46:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMXRT1010-crashes-when-enabling-interrupt/m-p/1771539#M217104</guid>
      <dc:creator>youngSheldon</dc:creator>
      <dc:date>2023-12-08T12:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: iMXRT1010 crashes when enabling interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMXRT1010-crashes-when-enabling-interrupt/m-p/1771779#M217114</link>
      <description>&lt;P&gt;I possibly found the root cause, after a quick chat with a friend (credit goes to him). If anything changes, I'll update the post.&lt;/P&gt;&lt;P&gt;I was missing the IRQ definition for 0_15 pins as I wasn't actually using them in my app, and it works so far. IRQ was probably triggered by a pull up/down before LINK could control the MCU. It also makes sense to have the code break when initializing 16_31 IRQ, as it needed some CLK time to trigger 0_15 IRQ.&lt;/P&gt;&lt;P&gt;I added the first 2 lines to existing code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define GPIO1_LoIrqHandler 	GPIO1_GPIO_COMB_0_15_IRQHANDLER
#define GPIO1_LoIRQ			GPIO1_GPIO_COMB_0_15_IRQN
#define GPIO1_HiIrqHandler 	GPIO1_GPIO_COMB_16_31_IRQHANDLER
#define GPIO1_HiIRQ			GPIO1_GPIO_COMB_16_31_IRQN&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and defined a minimal IRQ function, just enough to take care of the IRQ flags:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void GPIO1_LoIrqHandler(void) {
	/* Get pins flags */
	uint32_t pins_flags = GPIO_GetPinsInterruptFlags(GPIO1);
	/* Clear ins flags */
	GPIO_ClearPinsInterruptFlags(GPIO1, pins_flags);
	/* 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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2023 07:03:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMXRT1010-crashes-when-enabling-interrupt/m-p/1771779#M217114</guid>
      <dc:creator>youngSheldon</dc:creator>
      <dc:date>2023-12-09T07:03:25Z</dc:date>
    </item>
  </channel>
</rss>

