Anyone know how to get interrupts to work on the i.mxrt1176 ? - Page 1
Forum section: electronics / general

author: SpacedCowboy
author_rank: Frequent Contributor
timestamp: July 19, 2023, 02:13:42 am
content: I've basically put a CM4 project together, and as far as I can see, the only 2 relevant files are pin_mux.c and file containing main(). I'm trying to just trigger an interrupt on Pin N15, brought out to J9 on the EVK board. I know (can see on the logic analyser) that there is a signal going into it. I just don't seem to be getting any calls to the interrupt handler...Here's the auto-generated pin_mux.c from the IDE:Code:#include "fsl_common.h"#include "fsl_iomuxc.h"#include "fsl_gpio.h"#include "pin_mux.h"/* FUNCTION ************************************************************************************************************** Function Name : BOARD_InitBootPins* Description : Calls initialization functions.** END ****************************************************************************************************************/void BOARD_InitBootPins(void) {BOARD_InitPins();}/** TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************BOARD_InitPins:- options: {callFromInitBoot: 'true', coreID: cm4, enableClock: 'true'}- pin_list:- {pin_num: N15, peripheral: GPIO3, signal: 'gpio_mux_io, 16', pin_signal: GPIO_AD_17, direction: INPUT, gpio_interrupt: kGPIO_IntRisingEdge, software_input_on: Enable,slew_rate: Fast}* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ************//* FUNCTION ************************************************************************************************************** Function Name : BOARD_InitPins, assigned for the Cortex-M4F core.* Description : Configures pin routing and optionally pin electrical features.** END ****************************************************************************************************************/void BOARD_InitPins(void) {CLOCK_EnableClock(kCLOCK_Iomuxc); /* LPCG on: LPCG is ON. *//* GPIO configuration of A8_CLK on GPIO_AD_17 (pin N15) */gpio_pin_config_t A8_CLK_config = {.direction = kGPIO_DigitalInput,.outputLogic = 0U,.interruptMode = kGPIO_IntRisingEdge};/* Initialize GPIO functionality on GPIO_AD_17 (pin N15) */GPIO_PinInit(GPIO3, 16U, &A8_CLK_config);/* Enable GPIO pin interrupt on GPIO_AD_17 (pin N15) */GPIO_PortEnableInterrupts(GPIO3, 1U << 16U);IOMUXC_SetPinMux(IOMUXC_GPIO_AD_17_GPIO_MUX3_IO16, /* GPIO_AD_17 is configured as GPIO_MUX3_IO16 */1U); /* Software Input On Field: Force input path of pad GPIO_AD_17 */IOMUXC_GPR->GPR43 = ((IOMUXC_GPR->GPR43 &(~(BOARD_INITPINS_IOMUXC_GPR_GPR43_GPIO_MUX3_GPIO_SEL_HIGH_MASK))) /* Mask bits to zero which are setting */| IOMUXC_GPR_GPR43_GPIO_MUX3_GPIO_SEL_HIGH(0x00U) /* GPIO3 and CM7_GPIO3 share same IO MUX function, GPIO_MUX3 selects one GPIO function: 0x00U */);IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_17_GPIO_MUX3_IO16, /* GPIO_AD_17 PAD functional properties : */0x07U); /* Slew Rate Field: Fast Slew RateDrive Strength Field: high drive strengthPull / Keep Select Field: Pull EnablePull Up / Down Config. Field: Weak pull downOpen Drain Field: DisabledDomain write protection: Both cores are allowedDomain write protection lock: Neither of DWP bits is locked */}and here's the main.cpp file:Code:#include <stdio.h>#include "board.h"#include "peripherals.h"#include "pin_mux.h"#include "fsl_iomuxc.h"#include "clock_config.h"#include "MIMXRT1176_cm4.h"#include "fsl_debug_console.h"/* TODO: insert other include files here. *//* TODO: insert other definitions and declarations here. */volatile uint32_t g_counter = 0;void GPIO3_Combined_16_31_IRQHandler(void){/* clear the interrupt status */GPIO_PortClearInterruptFlags(GPIO3, 1 << 16U);/* Change state of switch. */g_counter ++;SDK_ISR_EXIT_BARRIER;}/** @brief Application entry point.*/int main(void) {/* Init board hardware. */BOARD_InitBootPins();BOARD_InitBootClocks();BOARD_InitBootPeripherals();#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL/* Init FSL debug console. */BOARD_InitDebugConsole();#endifPRINTF("Hello World\n");/* Force the counter to be placed into memory. */volatile static uint32_t i = 0;/* Enter an infinite loop, just checking the counter. */while(1) {if (i != g_counter){PRINTF("Counter: %lu\n", g_counter);i = g_counter;}}return 0 ;}As far as I can tell,GPIO3_Combined_16_31_IRQHandleris the correct irq handler, and it's printing out "Hello World", but never entering the interrupt handler itself (or at least, the unconditional breakpoint is never triggering whereas the enter-main breakpoint does).Just wondering if there's some a-priori knowledge which someone might be able to share (like: you need to enablethisproject option to get interrupts at all..), or if there's something obviously wrong above - I'd normally ask this sort of thing on the vendor forum, but NXP's forum has been down since last Friday...Thanks in advance for any help

author: jnk0le
author_rank: Regular Contributor
timestamp: July 19, 2023, 06:21:11 pm
content: probably missing NVIC_EnableIRQ(GPIO3_Combined_16_31_IRQn)

author: SpacedCowboy
author_rank: Frequent Contributor
timestamp: July 19, 2023, 07:15:00 pm
content: That ... was it. Thank youBased on the name, I was foolishly expectingCode:/* Enable GPIO pin interrupt on GPIO_AD_17 (pin N15) */GPIO_PortEnableInterrupts(GPIO3, 1U << 16U);to do that, but it just sets the mask on that actual GPIO, it doesn't enable the handler in the NVIC...Ah well, live and learn.