Arm STM32 freertos线程不工作
我正试图通过使用gnuarmeclipse和openstm32插件ans STM32F41RE NucleoBoard在Eclipse上实现一个小型freeRTOS项目。项目正在进行构建,当GPIO设置和重置功能在主功能内使用时,连接到端口A针脚5的LED闪烁。但在使用线程时,它不起作用。我在这里添加代码。 谢谢你宝贵的时间Arm STM32 freertos线程不工作,arm,eclipse-cdt,stm32,rtos,freertos,Arm,Eclipse Cdt,Stm32,Rtos,Freertos,我正试图通过使用gnuarmeclipse和openstm32插件ans STM32F41RE NucleoBoard在Eclipse上实现一个小型freeRTOS项目。项目正在进行构建,当GPIO设置和重置功能在主功能内使用时,连接到端口A针脚5的LED闪烁。但在使用线程时,它不起作用。我在这里添加代码。 谢谢你宝贵的时间 #include "stm32f4xx.h" #include "cmsis_os.h" #include "stdio.h" #include "stm32f4x
#include "stm32f4xx.h"
#include "cmsis_os.h"
#include "stdio.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
static void StartThread(void const * argument);
static void SecondThread(void const * argument);
static void GPIO_Init2(void);
void Delay2(int);
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
int main(void)
{
GPIO_Init2();
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
osThreadDef(USER_Thread1, StartThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
osThreadDef(USER_Thread2, SecondThread, osPriorityNormal, 0, configMINIMAL_STACK_SIZE);
osThreadCreate (osThread(USER_Thread1), NULL);
osThreadCreate (osThread(USER_Thread2), NULL);
/* Start scheduler */
osKernelStart();
while (1){
}
}
void Delay2(int nCount)
{
while(nCount--){
int a=5000;
while(a--){
}
}
}
void GPIO_Init2(void)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA ,ENABLE);
GPIO_InitTypeDef GPIO_InitDef;
GPIO_InitDef.GPIO_Pin = GPIO_Pin_5;
GPIO_InitDef.GPIO_Mode=GPIO_Mode_OUT;
GPIO_InitDef.GPIO_OType=GPIO_OType_PP;
GPIO_InitDef.GPIO_PuPd=GPIO_PuPd_NOPULL;
GPIO_InitDef.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitDef);
GPIO_SetBits(GPIOA,GPIO_Pin_5);
osDelay(50);
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
osDelay(100);
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/* StartDefaultTask function */
static void StartThread(void const * argument)
{
while(1) {
GPIO_SetBits(GPIOA,GPIO_Pin_5);
osDelay(500);
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
osDelay(100);
}
}
static void SecondThread(void const * argument)
{
while(1) {
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif
您不能在GPIO_Init2函数中使用osDelay,因为调度程序尚未启动osKernelStart。osThreadDef、osThreadCreate和osKernelStart不是FreeRTOS API的一部分。你真的在用FreeRTOS吗?你打算如何让你的两个任务在运行和阻塞之间切换?osDelay做什么?你的任务真的应该有相同的功能吗?你在使用时间切片吗?RTOS内核是否需要周期性的滴答声源?您是否配置了硬件计时器来提供该滴答声?最好从FreeRTOS的一个演示应用开始。谢谢。我又从一个演示开始。但是获取对vTaskDelay、xTaskCreate的错误未定义引用。我在demos文件夹中找不到用于eclipse的stm32f4批处理文件。请帮我解决这个问题。使用openstm32插件2在eclipse中创建了STM3F411RE项目。从项目(包括std periph库)复制了freeRTOS文件夹。3.在另一个项目中删除main.c并替换为hello_world.c。4.包括来自同一项目的FreeRTOS配置头stm32f4xx_it.h。c编译器和汇编程序包含路径的免费rtos包含路径和CM4路径。6.修改了主代码以删除对发现库的依赖关系。