Issues when adding a simple RT task

I had a simple code to my project for the ESP32 that basically SCAN Wifis nad then allows you to connect to any of the networks selecting the SSID and password. Works perfectly until i decied to add a real time task that cheks every 500 ms if the connection is still active and print something (simple as that).

Blockquote
xTaskCreatePinnedToCore(
check_net,
“check_net”,
2000,
NULL,
2,
NULL,
0);
void check_net(void * parameter){
if(WiFi.status()!=WL_CONNECTED) Serial.println(“Conexión perdida.Reconectando…”);
else Serial.println(“Todo en orden jefe WOF WOF.”);
vTaskDelay(5000/portTICK_PERIOD_MS);
}

Now the issue I find is that as soon as the task activates I get this in the terminal:

Blockquote
Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d2814: 2fe5f604 000090bb 46d0a7a2
Core 0 register dump:
PC : 0x400d2819 PS : 0x00060130 A0 : 0x00000000 A1 : 0x3ffcfaa0
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800d2819 A9 : 0x3ffcfa80
A10 : 0x00001388 A11 : 0x3ffbf528 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x3ffcea8c A15 : 0x80000001 SAR : 0x00000000 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace: 0x400d2816:0x3ffcfaa0

ELF file SHA256: 300426ae34e0ad6b

Rebooting…
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13104
load:0x40080400,len:3036
entry 0x400805e4

I have no idea how to solve this. I tried to switch between cores or change the stack size but the problem still exist. I’d apreciate any help. Thanks.

Your FreeRTOS task seems to return without deleting itself which is not allowed. Usually a FreeRTOS task contains an infinite loop. Does the problem still persist if you update the task definition to the following -

void check_net(void * parameter)
{
    for( ;; )
    {
        if( WiFi.status() != WL_CONNECTED) 
        {
            Serial.println( "Conexión perdida.Reconectando…" );
        }
        else
        {
            Serial.println( "Todo en orden jefe WOF WOF." );
        }

        vTaskDelay( pdMS_TO_TICKS( 5000 ) );
    }
}

Working perfectly. The issue was the absence of the for loop. Thanks very much.