I need help on how to continuously write fast data to pin

HIBFITAS
Posts: 1
Joined: Thu Aug 05, 2021 2:31 am

I need help on how to continuously write fast data to pin

Postby HIBFITAS » Sat Apr 09, 2022 3:08 am

How to do a fast loop on core 0 or core 1 without it stops/crash/reset by the stack length.
I use: xTaskCreatePinnedToCore but it keeps resetting on my oscilloscope because of /* Stack size of task */.
How to bypass the stack so it can run continuously without stopping.


very very short and lazy example below

xTaskCreatePinnedToCore(
taskon2core, /* Task function. */
"Task2", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&Task2, /* Task handle to keep track of created task */
1); /* pin task to core 1 */
delay(500);
}


void taskon2core( void * _newPointer ){
for(;;){
digitalWrite(led2, HIGH);
delay(700);
digitalWrite(led2, LOW);
delay(700);
}
}

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: I need help on how to continuously write fast data to pin

Postby mbratch » Sat Apr 09, 2022 5:52 pm

1400ms period isn't really very fast. :)

In a FreeRTOS task you should be calling `vTaskDelay`, not `delay`.

For a periodic pulse you might also consider using a FreeRTOS software timer rather than using a task with delays. For your example you would set up a 700ms timer that keeps track of a static state for the pin, toggling it on or off. That would not involve using a delay at all.

mikemoy
Posts: 626
Joined: Fri Jan 12, 2018 9:10 pm

Re: I need help on how to continuously write fast data to pin

Postby mikemoy » Sun Apr 10, 2022 6:11 pm

How about using the LEDC (LED Controller) ?

Who is online

Users browsing this forum: No registered users and 100 guests