The problem with keeping a gpio output high all the time in freertos

I created a new freertos task and initially pulled a gpio pin high in the task, it was very simple. But when I monitor the waveform of this pin with an oscilloscope, I found that this pin is not always high, when freertos does time slice task scheduling and switches tasks, this pin will return to the low initial state, I tried a lot methods, such as using preemptive scheduling instead, or setting this pin in all tasks, but none solved the problem.
Here is my code:

void testTask1(void* *pvParameters)
		gpio_bit_set(GPIOD, GPIO_PIN_4);

void main(void)

	xTaskCreate(testTask5, "test_task5", 128, NULL, 1, NULL);

but the task function in your post is testTask1.
I guess there are some more tasks manipulating the GPIO pin.
I don’t know what you’re trying to test but manipulating the same GPIO controller with it’s pins in multiple tasks requires some access protection (a mutex).

1 Like