Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TaskHandle_t Task1;
- TaskHandle_t Task2;
- TaskHandle_t Task3;
- unsigned long previousTime, previousTime1, previousTime2, previousTime3;
- void setup() {
- Serial.begin(115200);
- //create a task on core 0 that will be execute task1Func() with priority 10
- xTaskCreatePinnedToCore(
- task1Func, /* Task function. */
- "Task1", /* name of task. */
- 10000, /* Stack size of task */
- NULL, /* parameter of the task */
- 10, /* priority of the task */
- &Task1, /* Task handle to keep track of created task */
- 0); /* pin task to core 0 */
- delay(500);
- //create a task on core 1 that will be execute task2Func() with priority 9
- xTaskCreatePinnedToCore(
- task2Func, /* Task function. */
- "Task2", /* name of task. */
- 10000, /* Stack size of task */
- NULL, /* parameter of the task */
- 9, /* priority of the task */
- &Task2, /* Task handle to keep track of created task */
- 1); /* pin task to core 1 */
- delay(500);
- xTaskCreatePinnedToCore(
- task3Func,
- "Task3",
- 10000,
- NULL,
- 8,
- &Task3,
- 0);
- }
- void task1Func( void * pvParameters ) {
- for (;;) {
- Serial.printf("%s running on core %d (priorite %d) - %dms\n", "Task1", xPortGetCoreID(), uxTaskPriorityGet( NULL ), millis() - previousTime1);
- previousTime1 = millis();
- delay(200);//vTaskDelay( pdMS_TO_TICKS( 200 ) );
- }
- }
- void task2Func( void * pvParameters ) {
- for (;;) {
- Serial.printf("%s running on core %d (priorite %d) - %dms\n", "Task2", xPortGetCoreID(), uxTaskPriorityGet( NULL ), millis() - previousTime2);
- previousTime2 = millis();
- delay(600);
- //vTaskDelay( pdMS_TO_TICKS( 600 ) );
- }
- }
- void task3Func( void *pvParameters )
- {
- for ( ;; )
- {
- Serial.printf("%s running on core %d (priorite %d) - %dms\n", "Task3", xPortGetCoreID(), uxTaskPriorityGet( NULL ), millis() - previousTime3);
- previousTime3 = millis();
- delay(100);
- //vTaskDelay( pdMS_TO_TICKS( 100 ) );
- }
- }
- void loop() {
- Serial.printf("%s running on core %d (priorite %d) - %dms\n", "loop()", xPortGetCoreID(), uxTaskPriorityGet( NULL ), millis() - previousTime);
- previousTime = millis();
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement