Hello,
I want to implement Timer overflow Interrupt on MCU2_0 core (RTOS). I'm running a Linux app on the A72 core that uses remote services for sending command to mcu2_0 and running RTOS code on mcu2_0 (main_app() in the following code snippet). This is my code:
#define UTILS_TIMER_BASE (CSL_TIMER18_CFG_BASE) #define TEST_TIMER_INT_NUM (CSLR_R5FSS0_CORE0_INTR_TIMER18_INTR_PEND_0) static void timerIsr(uintptr_t arg) { /* Disable the Timer interrupts */ TIMERIntDisable(UTILS_TIMER_BASE, TIMER_INT_OVF_EN_FLAG); /* acknowledge the interrupt */ TIMERIntStatusClear(UTILS_TIMER_BASE, TIMER_IRQSTATUS_OVF_IT_FLAG_MASK); timerIsrCount++; printf("ISR %d \n", timerIsrCount); /* Enable the Timer interrupts */ TIMERIntEnable(UTILS_TIMER_BASE, TIMER_INT_OVF_EN_FLAG); } static int32_t Utils_timerConfigIntr() { int32_t testStatus; OsalInterruptRetCode_e retVal; OsalRegisterIntrParams_t interruptRegParams; /* Initialize with defaults */ Osal_RegisterInterrupt_initParams(&interruptRegParams); /* Populate the interrupt parameters */ interruptRegParams.corepacConfig.arg = (uintptr_t) UTILS_TIMER_BASE; interruptRegParams.corepacConfig.name = NULL; interruptRegParams.corepacConfig.isrRoutine = timerIsr; interruptRegParams.corepacConfig.triggerSensitivity = OSAL_ARM_GIC_TRIG_TYPE_HIGH_LEVEL; interruptRegParams.corepacConfig.priority = 1; interruptRegParams.corepacConfig.intVecNum = TEST_TIMER_INT_NUM; /* Host Interrupt vector */ interruptRegParams.corepacConfig.corepacEventNum = 0u; /* Register interrupts */ retVal = Osal_RegisterInterrupt(&interruptRegParams, &(gdmTimerTest_HwiPHandle)); if (retVal == OSAL_INT_SUCCESS) { testStatus = CSL_APP_TEST_PASS; printf("Interrupt registration successfull.\n"); } else { testStatus = CSL_APP_TEST_FAILED; printf("Interrupt registration error: %d!\n", retVal); } return (testStatus); } static void Utils_timerSetup(void) { Utils_timerConfigIntr(); /* Reset the timer module */ TIMERReset(UTILS_TIMER_BASE); /* Enable free run in emulation mode */ TIMEREmuModeConfigure(UTILS_TIMER_BASE, TIMER_FREE); /* Load the counter with the initial count value */ TIMERCounterSet(UTILS_TIMER_BASE, 0xFF000000U); /* Load the load register with the reload count value */ TIMERReloadSet(UTILS_TIMER_BASE, TIMER_RELOAD_VALUE); /* Configure the Timer for Auto-reload and compare mode */ TIMERModeConfigure(UTILS_TIMER_BASE, TIMER_AUTORLD_NOCMP_ENABLE); /* Configure the posted mode of TIMER */ TIMERPostedModeConfig(UTILS_TIMER_BASE, TIMER_NONPOSTED); /* Configure the read mode of TIMER */ TIMERReadModeConfig(UTILS_TIMER_BASE, TIMER_READ_MODE_POSTED); TIMERIntStatusClear(UTILS_TIMER_BASE, TIMER_INT_OVF_IT_FLAG); TIMERIntEnable(UTILS_TIMER_BASE, TIMER_INT_OVF_EN_FLAG); TIMERIntStatusClear(UTILS_TIMER_BASE, TIMER_INT_OVF_IT_FLAG); /* Start the Timer */ // TIMEREnable(UTILS_TIMER_BASE); } void main_app(void) { uint32_t key; Utils_timerSetup(); key = HwiP_disable(); /* Clear the timer interrupt */ HwiP_clearInterrupt(TEST_TIMER_INT_NUM); HwiP_enableInterrupt(TEST_TIMER_INT_NUM); HwiP_restore(key); /* Start the Timer */ TIMEREnable(UTILS_TIMER_BASE); while(1) { /* test loop */ TaskP_sleepInMsecs(1000); printf("Main loop. Timer val: %ul \n", HW_RD_REG32(UTILS_TIMER_BASE + TIMER_TCRR)); } }
The problem is that ISR doesn't run when Timer generate an interrupt.
Also, another maybe bigger problem is that code execution is getting stuck in while(1) loop (only one printf() with timer value is printed in terminal).
But, if I run this code without Interrupt registration (Utils_timerConfigIntr()), then there is no problems with getting stuck in while(1).
Please, can you check my code? What is missing and what is wrong? How to implement code to enable ISR triggering on every timer overflow interrupt?
Best regards,
Darko