Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6814

SDK • FreeRTOS SMP - Share tick with other core

$
0
0
Hi there,

I am struggling to make vTaskDelay work for tasks that are running on the second core (or the one without the tick, see

Code:

config_TICK_CORE
.

This is my minimal example where the FreeRTOS_Config stems 1-to-1 from the pico-examples:

Code:

void blink_task(void* params) {  const int32_t value = *reinterpret_cast<int32_t*>(params);  while (true) {    printf("Blinking LED...%d\n", value);    vTaskDelay(1000);  }}void main_task(__unused void* params) {  // POSITION 1  // int32_t value3 = -5;  // xTaskCreateAffinitySet(blink_task, "BlinkTask", 2048, &value3, 1, 2, NULL);  int count = 0;  while (true) {    printf("Hello from main task count=%u\n", count++);    vTaskDelay(3000);  }}void VLaunch(void) {  TaskHandle_t task;  xTaskCreateAffinitySet(main_task, "MainThread", 2048, NULL, 1, 1, &task);  // POSITION 2  int32_t value3 = -5;  xTaskCreateAffinitySet(blink_task, "BlinkTask", 2048, &value3, 1, 2, NULL);  /* Start the tasks and timer running. */  vTaskStartScheduler();}/*** * Main * @return */int main(void) {  if (!stdio_init_all()) {    return 1;  }  busy_wait_ms(1000);  printf("Starting FreeRTOS SMP on both cores...\n");  VLaunch();  return 0;}
You can see the BlinkTask is pinned to core 1, while the main one is running on core 0.

When POSITION 1 is active, stdout is filled with "BlinkingLED...", the delay is not held and the main task never outputs.

When POSITION 2 is active, the BlinkTask prints once then never again. The main task outputs as expected.

If I move the BlinkTask to core 0 then everything is fine.

I am wondering what is the proper way to share the tick between cores?

I thank you very much already for any tips!

Forgot to mention: platform is a Pico W, SDK v2.1.1

Statistics: Posted by 22sunit — Tue May 20, 2025 1:01 pm — Replies 0 — Views 38



Viewing all articles
Browse latest Browse all 6814

Trending Articles