21ic问答首页 - HC32L190 定时器中断不进入
HC32L190 定时器中断不进入
l4598296342021-10-30
使用华大单片机碰到一些问题,不知道有人能帮我解决吗?
void time0_Init(void)
{
uint16_t u16ArrValue;
uint16_t u16CntValue;
stc_bt_mode0_cfg_t stcBtBaseCfg;
DDL_ZERO_STRUCT(stcBtBaseCfg);
Sysctrl_SetPeripheralGate(SysctrlPeripheralBaseTim, TRUE);
stcBtBaseCfg.enWorkMode = BtWorkMode0;
stcBtBaseCfg.enCT = BtTimer;
stcBtBaseCfg.enPRS = BtPCLKDiv16;
stcBtBaseCfg.enCntMode = Bt16bitArrMode;
stcBtBaseCfg.bEnTog = FALSE;
stcBtBaseCfg.bEnGate = FALSE;
stcBtBaseCfg.enGateP = BtGatePositive;
Bt_Mode0_Init(TIM0, &stcBtBaseCfg);
u16ArrValue = 0x10000 - 1600;
Bt_M0_ARRSet(TIM0, u16ArrValue);
u16CntValue = 0x10000 - 1600;
Bt_M0_Cnt16Set(TIM0, u16CntValue);
Bt_ClearIntFlag(TIM0,BtUevIrq);
Bt_Mode0_EnableIrq(TIM0);
EnableNvic(TIM0_IRQn, IrqLevel3, TRUE);
}
我开启定时中断,为什么不进入中断,而且我发现整个中断函数都不运行,不知道怎么回事,有人知道吗?
还有就是我使用模拟IIC,来读取DS1307,读到的数据全是0
void DS1302_Init(void)
{
stc_gpio_cfg_t stcGpioCfg;
Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);
stcGpioCfg.enDir = GpioDirOut;
stcGpioCfg.enDrv = GpioDrvH;
stcGpioCfg.enPu = GpioPuEnable;
stcGpioCfg.enPd = GpioPdDisable;
stcGpioCfg.enOD = GpioOdDisable;
stcGpioCfg.enCtrlMode = GpioAHB;
stcGpioCfg.bOutputVal = TRUE;
Gpio_Init(GpioPortB, GpioPin3, &stcGpioCfg);
Gpio_Init(GpioPortB, GpioPin4, &stcGpioCfg);
if(Read_DS1302(0x08) != 0xF0)
{
Write_DS1302(write_address[0], 0x30); //Ãë
Write_DS1302(write_address[1], 0x09); //·Ö
Write_DS1302(write_address[2], 0x15); //ʱ
Write_DS1302(write_address[3], 0x29); //ÈÕ
Write_DS1302(write_address[4], 0x09); //ÔÂ
Write_DS1302(write_address[5], 0x03); //ÖÜ
Write_DS1302(write_address[6], 0x21); //Äê
Write_DS1302(0x08, 0xF0);
}
}
这是什么原因
void time0_Init(void)
{
uint16_t u16ArrValue;
uint16_t u16CntValue;
stc_bt_mode0_cfg_t stcBtBaseCfg;
DDL_ZERO_STRUCT(stcBtBaseCfg);
Sysctrl_SetPeripheralGate(SysctrlPeripheralBaseTim, TRUE);
stcBtBaseCfg.enWorkMode = BtWorkMode0;
stcBtBaseCfg.enCT = BtTimer;
stcBtBaseCfg.enPRS = BtPCLKDiv16;
stcBtBaseCfg.enCntMode = Bt16bitArrMode;
stcBtBaseCfg.bEnTog = FALSE;
stcBtBaseCfg.bEnGate = FALSE;
stcBtBaseCfg.enGateP = BtGatePositive;
Bt_Mode0_Init(TIM0, &stcBtBaseCfg);
u16ArrValue = 0x10000 - 1600;
Bt_M0_ARRSet(TIM0, u16ArrValue);
u16CntValue = 0x10000 - 1600;
Bt_M0_Cnt16Set(TIM0, u16CntValue);
Bt_ClearIntFlag(TIM0,BtUevIrq);
Bt_Mode0_EnableIrq(TIM0);
EnableNvic(TIM0_IRQn, IrqLevel3, TRUE);
}
我开启定时中断,为什么不进入中断,而且我发现整个中断函数都不运行,不知道怎么回事,有人知道吗?
还有就是我使用模拟IIC,来读取DS1307,读到的数据全是0
void DS1302_Init(void)
{
stc_gpio_cfg_t stcGpioCfg;
Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);
stcGpioCfg.enDir = GpioDirOut;
stcGpioCfg.enDrv = GpioDrvH;
stcGpioCfg.enPu = GpioPuEnable;
stcGpioCfg.enPd = GpioPdDisable;
stcGpioCfg.enOD = GpioOdDisable;
stcGpioCfg.enCtrlMode = GpioAHB;
stcGpioCfg.bOutputVal = TRUE;
Gpio_Init(GpioPortB, GpioPin3, &stcGpioCfg);
Gpio_Init(GpioPortB, GpioPin4, &stcGpioCfg);
if(Read_DS1302(0x08) != 0xF0)
{
Write_DS1302(write_address[0], 0x30); //Ãë
Write_DS1302(write_address[1], 0x09); //·Ö
Write_DS1302(write_address[2], 0x15); //ʱ
Write_DS1302(write_address[3], 0x29); //ÈÕ
Write_DS1302(write_address[4], 0x09); //ÔÂ
Write_DS1302(write_address[5], 0x03); //ÖÜ
Write_DS1302(write_address[6], 0x21); //Äê
Write_DS1302(0x08, 0xF0);
}
}
这是什么原因
赞0
评论
2021-11-01
赞0
评论
2021-11-01
赞0
评论
2021-10-30
您需要登录后才可以回复 登录 | 注册