XU_xuxuxuxu 2019-10-28 16:11 采纳率: 0%
浏览 462

STM32F103CBT6上移植ucos操作系统 仿真后LED任务不运行一直处于空闲任务 是什么原因啊?

主函数
#include "stm32f10x.h"
#include "stm32f10x_conf.h"
#include "ucos_ii.h"
#define TASK_STK_SIZE 64 //定义堆栈长度
OS_STK LED0_TASK_STK[TASK_STK_SIZE];
OS_STK LED1_TASK_STK[TASK_STK_SIZE]; /*定义两个任务的堆栈数组*/
#define ON 0
#define OFF 1
#define LED0(a) if (a) \
GPIO_SetBits(GPIOA,GPIO_Pin_0);\
else \
GPIO_ResetBits(GPIOA,GPIO_Pin_0)
#define LED1(a) if (a) \
GPIO_SetBits(GPIOA,GPIO_Pin_1);\
else \
GPIO_ResetBits(GPIOA,GPIO_Pin_1) /*宏定义两个选择函数*/
void GPIO_configuration(void) //配置I/O口
{

GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /*开启GPIOA的外设时钟*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1; /*选择要控制的GPIOA引脚*/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /*设置引脚模式为通用推挽输出*/
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure); /*调用库函数,初始化GPIOA*/

/* 关闭led0灯 */
GPIO_SetBits(GPIOA, GPIO_Pin_0);
GPIO_SetBits(GPIOA, GPIO_Pin_1);

}
void BSP_Init(void) //硬件配置
{

GPIO_configuration(); /* GPIO端口初始化 /
}
void SysTick_init(void) /
SysTick_init 配置SysTick定时器 */
{
SysTick_Config(SystemCoreClock/OS_TICKS_PER_SEC); //初始化并使能SysTick定时器
}
void Task_LED0(void *p_arg)
{
(void)p_arg; // 'p_arg' 并没有用到,防止编译器提示警告
SysTick_init(); //在第一个任务中开启系统时钟

while (1)
{
LED0( ON );
OSTimeDlyHMSM(0, 0,0,100);
LED0( OFF);
OSTimeDlyHMSM(0, 0,0,100);

}
}
void Task_LED1(void *p_arg)
{
(void)p_arg; // 'p_arg' 并没有用到,防止编译器提示警告
while (1)
{
LED1( ON );
OSTimeDlyHMSM(0, 0,0,500);
LED1( OFF);
OSTimeDlyHMSM(0, 0,0,500);

}
}
int main(void)
{
BSP_Init();
OSInit();

OSTaskCreate(Task_LED0,(void *)0, &LED0_TASK_STK[TASK_STK_SIZE-1], 4);
OSTaskCreate(Task_LED1,(void *)0, &LED1_TASK_STK[TASK_STK_SIZE-1], 5);
OSStart();
return 0;
}
仿真后一直在空闲函数中运行
有大神知道是为什么吗

  • 写回答

2条回答 默认 最新

  • zqbnqsdsmd 2019-10-28 23:14
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿