0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vistaでstm32duino その19

Posted at

概要

vistaでstm32duinoやってみた。
freertos、やってみた。

サンプルコード

# include "STM32FreeRTOS.h"

const uint8_t LED_PIN = LED_BUILTIN;
volatile uint32_t count = 0;
TaskHandle_t blink;

static void vLEDFlashTask(void * pvParameters) {
	pinMode(LED_PIN, OUTPUT);
	for (;;) 
	{
		digitalWrite(LED_PIN, HIGH);
		vTaskDelay((50L * configTICK_RATE_HZ) / 1000L);
		digitalWrite(LED_PIN, LOW);
		vTaskDelay((150L * configTICK_RATE_HZ) / 1000L);
	}
}
static void vPrintTask(void * pvParameters) {
	while (1)  
	{
		vTaskDelay(configTICK_RATE_HZ);
		Serial.print(F("Count: "));
		Serial.print(count);
		Serial.print(F(", Unused Stack: "));
		Serial.print(uxTaskGetStackHighWaterMark(blink));
		Serial.print(' ');
		Serial.print(uxTaskGetStackHighWaterMark(0));
		Serial.print(' ');
		Serial.println(uxTaskGetStackHighWaterMark(xTaskGetIdleTaskHandle()));
		count = 0;
	}
}
void setup() {
	Serial.begin(9600);
	while(!Serial) {}
	xTaskCreate(vLEDFlashTask, "Task1", configMINIMAL_STACK_SIZE + 50, NULL, tskIDLE_PRIORITY + 2, &blink);
	xTaskCreate(vPrintTask, "Task2", configMINIMAL_STACK_SIZE + 100, NULL, tskIDLE_PRIORITY + 1, NULL);
	vTaskStartScheduler();
	Serial.println(F("Die"));
	while(1);
}
void loop() {
	while(1) 
	{
		noInterrupts();
		count++;
		interrupts();
	}
}





結果

Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108
Count: 9307985, Unused Stack: 163 194 108



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?