- 打卡等级:偶尔看看II
- 打卡总天数:20
- 最近打卡:2025-04-07 01:22:42
中级会员
- 积分
- 222
|
本帖最后由 135 于 2023-2-6 14:40 编辑
不可屏蔽中断的16位重装载模式,无法成功启动,用的是STC8G的官方库,代码如下
#include "timer.h"
#include "gpio.h"
void Timer_config(void) {
TIM_InitTypeDef TIMx;
TIMx.TIM_Mode = TIM_16BitAutoReloadNoMask;
TIMx.TIM_Priority = Priority_0;
TIMx.TIM_Interrupt = ENABLE;
TIMx.TIM_ClkSource = TIM_CLOCK_12T;
TIMx.TIM_ClkOut = DISABLE;
TIMx.TIM_Value = 0xffff + 1 - 1000;
TIMx.TIM_Run = ENABLE;
Timer_Inilize(Timer0, &TIMx);
}
void GPIO_config(void) {
GPIO_InitTypeDef GPIOx;
GPIOx.Mode = GPIO_PullUp;
GPIOx.Pin = GPIO_Pin_2;
GPIO_Inilize(GPIO_P3, &GPIOx);
}
void main() {
GPIO_config();
Timer_config();
EA = 1;
while(1) {
}
}
中断函数如下
void timer0_int (void) interrupt TIMER0_VECTOR
{
static u16 count = 0;
if(++count >= 1000) {
count = 0;
P32 = !P32;
}
}
请问哪里出了问题,感谢大佬
|
|