vMicro编译的STM32-FreeRTOS无法运行-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3710|回复: 1

vMicro编译的STM32-FreeRTOS无法运行

[复制链接]
发表于 2021-7-4 17:14 | 显示全部楼层 |阅读模式
使用STM32duino,上传到板上没有任何反应,有个闪灯程序也没反应
[pre]#include <STM32FreeRTOS.h>
#include <STM32LowPower.h>
int count = 0;
static void vTest(void* pvParameters)/// \effects 灯控制
{
        while (1)
        {
                digitalWrite(PC13, LOW);
                vTaskDelay(150);
                digitalWrite(PC13, HIGH);
                vTaskDelay(500);
                count++;
                if (count >= 5)
                {
                        LowPower.deepSleep(5000);
                        count = 0;
                }
        }
}

void setup() {
        // put your setup code here, to run once:
        pinMode(PC13, OUTPUT);
        LowPower.begin();//配置低功耗
        xTaskCreate(vTest, "ReadingCTask1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
        vTaskStartScheduler();//开始运行FreeRTOS
}

void loop() {
        // put your main code here, to run repeatedly:
}[/pre]
发表于 2021-7-30 12:19 | 显示全部楼层

不知你基于哪个软件编译的,我这边基于Stduino IDE软件和Stduino UNO mini硬件及STM32duino-FreeRTOS测试了下,可以正常使用,小蓝板之前也测试过可以正常使用
  1. /*
  2. * Example to demonstrate thread definition, semaphores, and thread sleep.
  3. */
  4. #include <STM32FreeRTOS.h>
  5. #include <Arduino.h>
  6. // Define the LED pin is attached
  7. const uint8_t LED_PIN = 13;

  8. // Declare a semaphore handle.
  9. SemaphoreHandle_t sem;
  10. //------------------------------------------------------------------------------
  11. /*
  12. * Thread 1, turn the LED off when signalled by thread 2.
  13. */
  14. // Declare the thread function for thread 1.
  15. static void Thread1(void* arg) {
  16.   UNUSED(arg);
  17.   while (1) {

  18.     // Wait for signal from thread 2.
  19.     xSemaphoreTake(sem, portMAX_DELAY);

  20.     // Turn LED off.
  21.     digitalWrite(LED_PIN, LOW);
  22.   }
  23. }
  24. //------------------------------------------------------------------------------
  25. /*
  26. * Thread 2, turn the LED on and signal thread 1 to turn the LED off.
  27. */
  28. // Declare the thread function for thread 2.
  29. static void Thread2(void* arg) {
  30.   UNUSED(arg);
  31.   pinMode(LED_PIN, OUTPUT);

  32.   while (1) {
  33.     // Turn LED on.
  34.     digitalWrite(LED_PIN, HIGH);

  35.     // Sleep for 1000 milliseconds.
  36.     vTaskDelay((1000L * configTICK_RATE_HZ) / 1000L);

  37.     // Signal thread 1 to turn LED off.
  38.     xSemaphoreGive(sem);

  39.     // Sleep for 1000 milliseconds.
  40.     vTaskDelay((1000L * configTICK_RATE_HZ) / 1000L);
  41.   }
  42. }
  43. //------------------------------------------------------------------------------
  44. void setup() {
  45.   portBASE_TYPE s1, s2;

  46.   Serial.begin(9600);

  47.   // initialize semaphore
  48.   sem = xSemaphoreCreateCounting(1, 0);

  49.   // create task at priority two
  50.   s1 = xTaskCreate(Thread1, NULL, configMINIMAL_STACK_SIZE, NULL, 2, NULL);

  51.   // create task at priority one
  52.   s2 = xTaskCreate(Thread2, NULL, configMINIMAL_STACK_SIZE, NULL, 1, NULL);

  53.   // check for creation errors
  54.   if (sem== NULL || s1 != pdPASS || s2 != pdPASS ) {
  55.     Serial.println(F("Creation problem"));
  56.     while(1);
  57.   }

  58.   // start scheduler
  59.   vTaskStartScheduler();
  60.   Serial.println("Insufficient RAM");
  61.   while(1);
  62. }

  63. //------------------------------------------------------------------------------
  64. // WARNING idle loop has a very small stack (configMINIMAL_STACK_SIZE)
  65. // loop must never block
  66. void loop() {
  67.   // Not used.
  68. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-12-1 05:31 , Processed in 0.087921 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表