2019-07-21 05:54发布
whj467467274672 发表于 2019-1-13 13:00 没用过UC但是用过其他RTOS,你的代码进不了中断,应该是裸机也进不了,RTOS进中断的时候最好告诉RTOS你进入 ...
三叶草 发表于 2019-1-13 09:14 操作系统又不会影响你的中断,进不了,估计是你配置有问题
最多设置5个标签!
void TIM3_Configuration(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_DeInit(TIM3);/
/* 设置TIM2CLK 为 72MHZ */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3 , ENABLE);
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period =1000; //当定时器从0计数到999,即为1000次,为一个定时周期
TIM_TimeBaseStructure.TIM_Prescaler = 71; //设置预分频:不预分频,即为72MHz
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ; //设置时钟分频系数:不分频(这里用不到)
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数模式
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_ClearFlag(TIM3, TIM_FLAG_Update);
TIM_ITConfig(TIM3,TIM_IT_Update, ENABLE); //使能update中断
/* TIM3 enable counter */
TIM_Cmd(TIM3, ENABLE); //使能定时器3
}
void TIM3_NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* 配置TIM3_IRQ中断为中断源 */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority =3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void TIM3_IRQHandler(void) //TIM3中断
{
OSIntEnter(); //用于统计中断的嵌套层数,对嵌套层数+1
/*if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查指定的TIM中断发生与否:TIM 中断源
{
//tim3_num++;
if ( tim3_num<=PWM_Hight)
{
Heat_OPEN ( );
}
else
{
Heat_CLOSED ( );
}
if ( tim3_num==100)
{
Heat_CLOSED ( );
}
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除TIMx的中断待处理位:TIM 中断源
}
OSIntExit(); //对嵌套层数减1,在退出中断前启动任务调度 */
}
这是相应的配置和中断代码
感谢,用原子自己的时间配置就可以了
一周热门 更多>