使用TimerA定时器来进行捕获输入,通过keil查看寄存器,定时器在计数,中断也使能了,但是无法进入中断服务函数,输入信号应该是没有问题的,我写了一个外部中断的代码,输入信号的三个引脚可以触发外部中断。是我配置的问题吗?
void TimerA_CaptureInit(void)
{
stc_timera_base_init_t stcTimeraInit;
stc_timera_capture_init_t stcTimeraCaptureInit;
stc_irq_regi_conf_t stcIrqRegiConf;
stc_port_init_t stcPortInit;
MEM_ZERO_STRUCT(stcTimeraInit);
MEM_ZERO_STRUCT(stcTimeraCaptureInit);
MEM_ZERO_STRUCT(stcIrqRegiConf);
MEM_ZERO_STRUCT(stcPortInit);
PWC_Fcg2PeriphClockCmd(PWC_FCG2_PERIPH_TIMA2,Enable);
// PWC_Fcg0PeriphClockCmd(PWC_FCG0_PERIPH_AOS,Enable);
PORT_SetFunc(TIMA_HALL_A_GPIO_PORT,TIMA_HALL_A_GPIO_PIN,Func_Tima2,Disable);
PORT_SetFunc(TIMA_HALL_B_GPIO_PORT,TIMA_HALL_B_GPIO_PIN,Func_Tima2,Disable);
PORT_SetFunc(TIMA_HALL_C_GPIO_PORT,TIMA_HALL_C_GPIO_PIN,Func_Tima2,Disable);
stcTimeraInit.enClkDiv = TimeraPclkDiv256;
stcTimeraInit.enCntDir = TimeraCountDirUp; //向上计数
stcTimeraInit.enCntMode = TimeraCountModeSawtoothWave; //三角波
stcTimeraInit.enSyncStartupEn = Disable;
stcTimeraInit.u16PeriodVal = TIMERA_COUNT_OVERFLOW;
TIMERA_BaseInit (M4_TMRA2,&stcTimeraInit);
stcTimeraCaptureInit.enCapturePwmRisingEn = Enable; //HICP0 采样到上升沿时捕获通道动作控制
stcTimeraCaptureInit.enCapturePwmFallingEn = Enable; //HICP1 采样到下降沿时捕获通道动作控制
stcTimeraCaptureInit.enCaptureSpecifyEventEn = Disable; //HICP2 专用比较时间触发通道动作控制
stcTimeraCaptureInit.enPwmClkDiv =TimeraFilterPclkDiv4; //NOFICK pwm滤波时钟选择
stcTimeraCaptureInit.enPwmFilterEn = Enable; //NOFIENCP 滤波功能控制
stcTimeraCaptureInit.enCaptureTrigRisingEn = Disable; //HICP3
stcTimeraCaptureInit.enCaptureTrigFallingEn = Disable; //HICP4
stcTimeraCaptureInit.enTrigClkDiv = TimeraFilterPclkDiv1;
stcTimeraCaptureInit.enTrigFilterEn =Disable;
TIMERA_CaptureInit(M4_TMRA2,TIMERA_UINT_CH1,&stcTimeraCaptureInit);
TIMERA_IrqCmd(M4_TMRA2,TIMERA_UNIT2_CH1_INT,Enable);
TIMERA_CaptureInit(M4_TMRA2,TIMERA_UINT_CH3,&stcTimeraCaptureInit);
TIMERA_IrqCmd(M4_TMRA2,TIMERA_UNIT2_CH3_INT,Enable);
TIMERA_CaptureInit(M4_TMRA2,TIMERA_UINT_CH4,&stcTimeraCaptureInit);
TIMERA_IrqCmd(M4_TMRA2,TIMERA_UNIT2_CH4_INT,Enable);
stcIrqRegiConf.enIntSrc = TIMERA_UNIT2_COMPARE_INT;
stcIrqRegiConf.enIRQn = Int000_IRQn;
stcIrqRegiConf.pfnCallback = &TimeraUnit2_IrqCallback;
enIrqRegistration(&stcIrqRegiConf);
NVIC_ClearPendingIRQ(stcIrqRegiConf.enIRQn);
NVIC_SetPriority(stcIrqRegiConf.enIRQn,DDL_IRQ_PRIORITY_00);
NVIC_EnableIRQ(stcIrqRegiConf.enIRQn);
// stcPortInit.enExInt = Enable;
// PORT_Init(KEY2_GPIO_PORT,KEY2_GPIO_PIN,&stcPortInit);
// TIMERA_SetCaptureTriggerSrc(EVT_PORT_EIRQ10);
TIMERA_Cmd(M4_TMRA2,Enable);
}
|
先试下官方例程能跑通不?