Part Number: BEAGLEBK
Hi,
I am trying to use the example code for DMTimer to initialize the timer in interrupt mode. It is not working, I am not able to generate the interrupt and not hitting the break point inside the callback function. Please review the code and help me solve the issue.
static volatile uint32_t gDmtimerIsrFlag = 0; /** \brief Application default configuration */ static const dmtimerAppCdt_t DMTIMER_APPCDT_DEFAULT = { 10U, /* cntValue */ { (uint32_t)DMTIMER_MODE_CFG_AUTORLD_CMP_DISABLE,/* configMode */ 0xFF000000U, /* timerInitialCount */ 0xFF000000U, /* timerReloadCount */ 0x0U, /* isClockPrescalerEnabled */ 0x0U, /* ClockPrescalerRatio */ INTC_TRIG_HIGH_LEVEL, /* trigType */ 100U, /* intrLine */ 1U, /* intrEnable */ (uint32_t)DMTIMER_INTR_MASK_OVF, /*intrFlag */ NULL, /* pFnIntrHandler */ NULL, /* pUserParam */ 2U, /* instNum */ (uint32_t)NULL /* instAddr */ } };
void Timer_App() { int32_t status = S_PASS; /* Initialize the global object with Countdown timer application. */ gDmtimerCdtApp = DMTIMER_APPCDT_DEFAULT; /* Enable cache memory and MMU */ /*MMUConfigAndEnable(); CACHEEnable(CACHE_IDCACHE, CACHE_INNER_OUTER);*/ // status = BOARDInit(NULL); /* Initialize the UART console */ /* CONSOLEUtilsInit(); Select the console type based on compile time check CONSOLEUtilsSetType(CONSOLE_UTILS_TYPE_UART); DEBUG_MSG("\n StarterWare DMTIMER - Countdown timer Application!!\n"); DEBUG_MSG("BOARDInit status [0x%x]\n", status);*/ /* Print SOC & Board Information. */ // SOCPrintInfo(); // BOARDPrintInfo(); /* Perform initialization of Interrupt controller*/ status = INTCInit(FALSE); if (S_PASS == status) { /*Find the instance on which to run this application or else dmtimer instance 2 will be used as default. */ status = DmtimerAppGetInstNum(&gDmtimerCdtApp); if (S_PASS == status) { /* Get SoC info -instance base address and interrupt line number*/ status = DmtimerAppGetSocInfo(&gDmtimerCdtApp); if (S_PASS == status) { /* Initialise the application parameters */ DMTIMERAppCountdownTimerInit(&gDmtimerCdtApp); /* Countdown timer use case with count down from 10 to 0 */ DMTIMERAppCountdownTimerRun(&gDmtimerCdtApp); DEBUG_MSG("\n Application Complete \n",__LINE__, __FILE__); } else { DEBUG_MSG("\n Application not supported in this SOC - \ exiting app! \n",__LINE__, __FILE__); } } else { DEBUG_MSG("\n This example is not supported on this SOC as\ no dmtimer instance could be found to support this example\ - exiting app! \n",__LINE__, __FILE__); } } else { DEBUG_MSG("Interrupt configuration failed - exiting app!\n",__LINE__, __FILE__); } while (1); }
/* * DMTimer interrupt service routine. This ISR sets the shared variable on * hitting an overflow interrupt - this is not a generic ISR */ void DmtimerAppCountdownIsr(uint32_t intrId, uint32_t cpuId, void* pUserParam) { dmtimerAppCdt_t *pCountdownTimerObj = (dmtimerAppCdt_t *)pUserParam; /* Disable the DMTimer interrupts */ DMTimerIntDisable(pCountdownTimerObj->dmtimerObj.instAddr, DMTIMER_INTR_MASK_OVF); /* Clear the status of the interrupt flags */ DMTimerIntStatusClear(pCountdownTimerObj->dmtimerObj.instAddr, DMTIMER_INTR_MASK_OVF); gDmtimerIsrFlag = 1U; /* Enable the DMTimer interrupts */ DMTimerIntEnable(pCountdownTimerObj->dmtimerObj.instAddr, DMTIMER_INTR_MASK_OVF); }
void DMTIMERAppCountdownTimerInit(dmtimerAppCdt_t *pCountdownTimerObj) { /*initialize the object ISR function pointer with application ISR*/ pCountdownTimerObj->dmtimerObj.pFnIntrHandler = &(DmtimerAppCountdownIsr); /*initialise the ISR user param with address of Countdown timer object */ pCountdownTimerObj->dmtimerObj.pUserParam = (void*)pCountdownTimerObj; /* call the peripheral config API */ DMTIMERAppInit((dmtimerAppCfg_t*)&(pCountdownTimerObj->dmtimerObj)); } void DMTIMERAppCountdownTimerRun(dmtimerAppCdt_t *pCountdownTimerObj) { // DEBUG_MSG("\n DMTIMER DOWN COUNTER: ",__LINE__, __FILE__); /* Start the DMTimer */ DMTIMEREnable(pCountdownTimerObj->dmtimerObj.instAddr, TRUE); while(pCountdownTimerObj->cntValue) { if(gDmtimerIsrFlag == 1) { // DEBUG_MSG("\b%d",(pCountdownTimerObj->cntValue - 1),__LINE__, __FILE__); pCountdownTimerObj->cntValue--; gDmtimerIsrFlag = 0U; } } }
The instance number is changing from 2 to 7. I have added the peripheral MMU in my main.cfg file for both DMTimer2 and DMTimer7 as follows:
/* DMTimer Base addresses*/ var peripheralBaseAddr = 0x4804A000; /* Configure the corresponding MMU page descriptor accordingly */ Mmu.setFirstLevelDescMeta(peripheralBaseAddr, peripheralBaseAddr, peripheralAttrs); var peripheralBaseAddr = 0x48040000; /* Configure the corresponding MMU page descriptor accordingly */ Mmu.setFirstLevelDescMeta(peripheralBaseAddr, peripheralBaseAddr, peripheralAttrs);
Please help I have been struggling to make this example project work since last 3 days.