static void App_Timer0Cfg(void)
{
stc_tmr0_init_t stcTmr0Init;
stc_clock_freq_t stcClockFreq;
static uint32_t u32Pclk12;
/* Enable timer0_1 clock */
FCG_Fcg2PeriphClockCmd(FCG2_PERIPH_TMR0_1, ENABLE);
/************************* Configure TMR0_1_A***************************/
(void)TMR0_StructInit(&stcTmr0Init);
stcTmr0Init.u32ClockSrc = TMR0_CLK_SRC_INTERN_CLK;
stcTmr0Init.u32ClockDiv = TMR0_CLK_DIV256;
stcTmr0Init.u32Func = TMR0_FUNC_CMP;
(void)CLK_GetClockFreq(&stcClockFreq);
u32Pclk12 = stcClockFreq.u32Pclk1Freq;
stcTmr0Init.u16CompareValue = (uint16_t)(u32Pclk12/256/1000 - 1);
(void)TMR0_Init(CM_TMR0_1, TMR0_CH_A, &stcTmr0Init);
TMR0_IntCmd(CM_TMR0_1, TMR0_INT_CMP_A, ENABLE);
/* TMR0 start counting */
TMR0_Start(CM_TMR0_1, TMR0_CH_A);
}
我用timer0, static uint32_t u32Pclk12;似乎和这个有关,static去掉就无法进中断, stcTmr0Init.u16CompareValue = (uint16_t)(u32Pclk12/256/1000 - 1);似乎是什么寄存器的值会变,感觉和芯片的架构有关 |