使用UC/OS-II创建任务出错
2015-04-29 09:00
288 查看
开发环境STM32F107VC+keil4.6+UC/OS-II+LWIP
在硬件调试过程中发现程序到了OSTaskCreate这一行后没有正确的创建任务。
单步调试,原来是
运行到第232行if(OSIntNesting>0u)是进入了条件语句直接返回了。分析应该是系统中断的问题,果不其然。原来的系统时钟中断是这样的:
就好了
在硬件调试过程中发现程序到了OSTaskCreate这一行后没有正确的创建任务。
<pre name="code" class="html">OSTaskCreate(start_task,(void *)0,(OS_STK *)&START_TASK_STK[START_STK_SIZE-1],START_TASK_PRIO );// OSStart();
单步调试,原来是
OS_ENTER_CRITICAL(); if (OSIntNesting > 0u) { /* Make sure we don't create the task from within an ISR */ OS_EXIT_CRITICAL(); return (OS_ERR_TASK_CREATE_ISR); } if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */ OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ... */ /* ... the same thing until task is created. */ OS_EXIT_CRITICAL(); psp = OSTaskStkInit(task, p_arg, ptos, 0u); /* Initialize the task's stack */ err = OS_TCBInit(prio, psp, (OS_STK *)0, 0u, 0u, (void *)0, 0u); if (err == OS_ERR_NONE) { if (OSRunning == OS_TRUE) { /* Find highest priority task if multitasking has started */ OS_Sched(); } } else { OS_ENTER_CRITICAL(); OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others */ OS_EXIT_CRITICAL(); } return (err);
运行到第232行if(OSIntNesting>0u)是进入了条件语句直接返回了。分析应该是系统中断的问题,果不其然。原来的系统时钟中断是这样的:
void SysTick_Handler(void) { OS_CPU_SR cpu_sr; OS_ENTER_CRITICAL(); // Tell uC/OS-II that we are starting an ISR OSIntNesting++; OS_EXIT_CRITICAL(); OSTimeTick(); // Call uC/OS-II's OSTimeTick() OSIntExit(); // Tell uC/OS-II that we are leaving the ISR }改为:
void SysTick_Handler(void) { OSIntEnter(); OSTimeTick(); OSIntExit(); // Tell uC/OS-II that we are leaving the ISR }
就好了
相关文章推荐
- 嵌入式上UC/OS - II使用注意点------任务调度
- uC/OS-II 学习笔记之:怎样在uC/OS-II里创建一个任务?
- UC/OS II 任务管理(4)之任务创建
- 为什么不使用动态内存的方法给uC/OS-II任务堆栈分配内存空间?
- uC/OS-II 学习笔记:任务创建步骤
- uC/OS-ii内核源码理解(五)创建任务函数
- 详解μC/OS-II如何检测任务堆栈实际使用情况——即如何设置ucosii任务堆栈大小
- uc/OSIII 任务使用
- uC/OS-ii内核理解(四)TCB任务控制块
- UC/OS-ii任务优先级管理与查找算法
- UC/OS II 任务管理(2)之就绪表和就绪组
- uC/OS-II任务机制理解
- UC/OS II 任务管理(3)之初始化
- UC/OS II 任务管理(5)之任务删除、阻塞和恢复
- UC/OS II 任务管理(6)之多任务启动
- uC/OS-ii在M3中的任务切换与任务堆栈
- UC/OS基础知识之任务的创建
- UC/OS-II基础知识之任务的同步与事件
- 改进uC/OS II,减少内存使用量
- uC/OS-II如何使任务在就绪表中进入就绪态与退出就绪态