21ic问答首页 - HC32L110 定时器怎么进不了中断?
HC32L110 定时器怎么进不了中断?
liboguang2022-04-25
使用官方的代码HC32L110_DDL_Rev1.1.4。也是进不去。这是问什么?/*******************************************************************************
* BT1中断服务函数
******************************************************************************/
void BtInt(void)
{
if (TRUE == Bt_GetIntFlag(TIM1))
{
Bt_ClearIntFlag(TIM1);
RunUart0FrameOut();
}
}
/*******************************************************************************
* BT定时功能测试 (重载模式)
******************************************************************************/
void Init_Timer1(void)
{
stc_bt_config_t stcConfig;
en_result_t enResult = Error;
uint16_t u16ArrData = 0x10000 - 100;
uint16_t u16InitCntData = 0x10000 - 100;//100us
Clk_SetPeripheralGate(ClkPeripheralBt,TRUE); //使能定时器时钟
stcConfig.pfnTim1Cb = BtInt;
stcConfig.enGateP = BtPositive;
stcConfig.enGate = BtGateEnable;
stcConfig.enPRS = BtPCLKDiv8; //时钟为PCLK 8分频
stcConfig.enTog = BtTogDisable;
stcConfig.enCT = BtTimer;
stcConfig.enMD = BtMode2;
//Bt初始化
if (Ok != Bt_Init(TIM1, &stcConfig))
{
enResult = Error;
}
//设置重载值和计数值,启动计数
Bt_ARRSet(TIM1, u16ArrData);
Bt_Cnt16Set(TIM1, u16InitCntData);
//TIM1中断使能
Bt_ClearIntFlag(TIM1);
Bt_EnableIrq(TIM1);
EnableNvic(TIM1_IRQn, 1, TRUE);
Bt_Run(TIM1);
}
* BT1中断服务函数
******************************************************************************/
void BtInt(void)
{
if (TRUE == Bt_GetIntFlag(TIM1))
{
Bt_ClearIntFlag(TIM1);
RunUart0FrameOut();
}
}
/*******************************************************************************
* BT定时功能测试 (重载模式)
******************************************************************************/
void Init_Timer1(void)
{
stc_bt_config_t stcConfig;
en_result_t enResult = Error;
uint16_t u16ArrData = 0x10000 - 100;
uint16_t u16InitCntData = 0x10000 - 100;//100us
Clk_SetPeripheralGate(ClkPeripheralBt,TRUE); //使能定时器时钟
stcConfig.pfnTim1Cb = BtInt;
stcConfig.enGateP = BtPositive;
stcConfig.enGate = BtGateEnable;
stcConfig.enPRS = BtPCLKDiv8; //时钟为PCLK 8分频
stcConfig.enTog = BtTogDisable;
stcConfig.enCT = BtTimer;
stcConfig.enMD = BtMode2;
//Bt初始化
if (Ok != Bt_Init(TIM1, &stcConfig))
{
enResult = Error;
}
//设置重载值和计数值,启动计数
Bt_ARRSet(TIM1, u16ArrData);
Bt_Cnt16Set(TIM1, u16InitCntData);
//TIM1中断使能
Bt_ClearIntFlag(TIM1);
Bt_EnableIrq(TIM1);
EnableNvic(TIM1_IRQn, 1, TRUE);
Bt_Run(TIM1);
}
您需要登录后才可以回复 登录 | 注册