我将 STM0 设置为 TC275 比较模式,以运行一个简单的操作系统。
在我的应用程序中,代码的运行符合预期。
现在,我开始在引导加载程序中使用相同的逻辑,但不幸的是,我发现在擦除/写入闪存后,定时器中断不再被触发。
调试时 我注意到STM0_CMP0 寄存器停止递增,但 STM0_tiM0 却一直正常运行。
下面是我的定时器代码和擦除功能的片段,其中我禁用了重置功能。
初始化函数
EXTERN bool_t IFX_OSISR_Initialise(void){ /* Set timer configuration to default values */ IfxStm_Timer_Config timerConfig; bool_t status = FALSE; IfxStm_Timer_initConfig( timerConfig, MODULE_STM0); timerConfig.base.frequency = IFX_OSISR_STM_CLK_FREQ; /* timer frequency */ timerConfig.base.isrPriority = ISR_PRIORITY_TIMER_STM; /* interrupt priority */ timerConfig.base.isrProvider = IfxSrc_Tos_cpu0; /* interrupt provider */ timerConfig.base.minResolution = (1.0 / timerConfig.base.frequency) / 1000; /* Mini resolution of the timer in seconds */ timerConfig.comparator = IfxStm_Comparator_0; /* Comparator used for timer */ /* Initialize the STM timer with the user configuration */ status = IfxStm_Timer_init( g_timerDriver, timerConfig);// IfxStm_Timer_setSingleMode( g_timerDriver,1); return status;}
启动功能
void IFX_OSISR_Start(void){ /* Start the STM */ IfxStm_Timer_run( g_timerDriver);}
中断处理程序
IFX_INTERRUPT(interruptHandlerSTM, 0, ISR_PRIORITY_TIMER_STM);
void interruptHandlerSTM(void){ /* Clear the interrupt flag and set the next compare value */ IfxStm_Timer_acknowledgeTimerIrq( g_timerDriver); /* Increment number of ticks since startup */ OsIsr_cntTicks = (OsIsr_cntTicks + 1u); /* execute handler of OS module */ OS_ActivateTask();}
我的擦除闪存功能按预期运行,而且是通过 SPRAM 运行的。
boolean iState = IfxCpu_disableInterrupts(); /* Get the current state of the interrupts and disable them*/ uint16 endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPasswordInline(); IfxScuWdt_clearSafetyEndinitInline(endInitSafetyPassword); /* Erase the given sector */ IfxFlash_eraseMultipleSectors(sector.startAddress, 1); IfxScuWdt_setSafetyEndinitInline(endInitSafetyPassword); IfxFlash_waitUnbusy(FLASH_MODULE0, sector.flashType); IfxCpu_restoreInterrupts(iState);
smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/AURIX-TC275-STM0-in-compare-mode-stops-triggering-interrupts-after-flash-erase/td-p/705592 |