Code: Select all
TaskHandle_t Task0;
TaskHandle_t Task1;
byte variable1=0;
byte variable2=0;
void setup(void) {
Serial.begin(115200);
//create a task that will be executed in the Task1code() function, with priority 1 and executed on core 0
xTaskCreatePinnedToCore(
Task0code, /* Task function. */
"Task0", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
2, /* priority of the task */
&Task0, /* Task handle to keep track of created task */
0); /* pin task to core 0 */
delay(500);
//create a task that will be executed in the Task2code() function, with priority 1 and executed on core 1
xTaskCreatePinnedToCore(
Task1code, /* Task function. */
"Task1", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
2, /* priority of the task */
// when priority was set to 100 then network scan would not complete
&Task1, /* Task handle to keep track of created task */
1); /* pin task to core 1 */
delay(500);
}
void loop() {
// put your main code here, to run repeatedly:
}
void Task0code( void * pvParameters ){
delay(1000);
for (;;){ //create an infinate loop
//Serial.println("variable1=" + String(variable1));
if(variable1>0){
variable1=0;
}else{
variable2=1;
}
delay(5);
if(variable2==1){
Serial.println("error");
delay(1000);
}
}
}
void Task1code( void * pvParameters ){
for (;;){ //create an infinate loop
variable1=1;
//delayMicroseconds(1);
}
}