金牌会员
 
- 积分
- 2282
- 金钱
- 2282
- 注册时间
- 2013-12-16
- 在线时间
- 448 小时
|
发表于 2016-4-29 10:07:18
|
显示全部楼层
本帖最后由 zdfwyh 于 2016-4-29 10:09 编辑
楼上是对的,有操作系统的情况下延时函数是会被强制打断去执行任务程序的.除非你在延时时关了中断,但这将严重破坏系统实时性,严重时会导致崩溃,在中断中加延时本身也是不允许的,必须要保证系统实时性,中断服务必须短小精悍,省时,做完就走.
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
LED=1;
}
void task_start (void *p_arg)
{
(void)p_arg;
{
while(1)
{
if(LED){ HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_RESET);LED=0;OSTimeDlyHMSM(0,1,0,0);}//点灯,延时1分钟
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_SET);//灭灯
}
}
} |
|