【STM32】FreeRTOS开启后,不再进入主函数的while(1)

开启freertos后,想在主函数的while(1)中实现led的翻转,发现无法实现。

cpp 复制代码
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Call init function for freertos objects (in freertos.c) */
  MX_FREERTOS_Init();

  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
		HAL_GPIO_TogglePin(GPIOF,GPIO_PIN_9);
		HAL_Delay(1000);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

分析原因:

cpp 复制代码
osKernelStart();

  /* We should never get here as control is now taken by the scheduler */

osKernelStart();

语句后面有一个注释:

/* We should never get here as control is now taken by the scheduler */

我们永远不会到达这里,因为控制权现在被调度器拿走了

相关推荐
LCG米37 分钟前
STM32硬件SPI驱动SSD1306 OLED实测:上电黑屏排查、页寻址模式与取模扫描方向陷阱
stm32·单片机·嵌入式硬件·嵌入式
深圳老胡1 小时前
STM32C5A3ZG 网络调试总结:从启动失败到连续 Ping 稳定
笔记·stm32·单片机·代码规范
qq_401700411 小时前
100 个 IoT 小项目,给 ESP32 入门补上实操
前端·网络·stm32
硅基造物主2 小时前
STM32 从 0 到 1 做智能家居(八):PWM 控制风扇、加热片与 SG90 窗帘
stm32·嵌入式硬件·智能家居·hal库·pwm
简单电磁炮2 小时前
关于adc采集
stm32·单片机
HQB20263 小时前
EG1163 (S)|屹晶微电子 600V 高压同步降压半桥控制器
嵌入式硬件·硬件工程
木由里予3 小时前
UFS 4.1 HID(Host Initiated Defragmentation)功能详解
嵌入式硬件
意法半导体STM323 小时前
【官方原创】如何在STM32CubeMX2中使用UART
stm32·单片机·嵌入式硬件
辛迪聊物业数字化5 小时前
物业费收缴率从68%提升到97%落地复盘:中小物业收费系统选型避坑指南
人工智能·嵌入式硬件·物联网·网络协议·系统架构
白搞电子5 小时前
ESP-Mosaico 轮滑动画编排台:拍点吸附、完整动作编辑与工程保存
单片机·嵌入式硬件·电脑