初级会员

- 积分
- 86
- 金钱
- 86
- 注册时间
- 2016-10-26
- 在线时间
- 27 小时
|
5金钱
使用UCOS-II系统,想在任务1中通过中断接收数据,然后在任务2中使用接收到的数据,那么如何才能让中断产生在任务1中?我写的程序大致如下:
.......各种初始化,创建任务,开始多任务调度........
static char p; //前面定义的
void task1(void *pdata)
{
使能串口接收中断;
while(1)
{
其他语句;
}
}
void task2(void *pdata)
{
while(1)
{
if(p)
语句1;
else
语句2;
延时;
}
}
void interrupt() //中断函数
{
OSIntEnter();
p=接收到的数据;
OSIntExit();
}
这样写对不对,能不能确保只在任务1进入中断,而在其他的任务中不会产生中断?如果不能实现,应该怎么修改?
|
|