vTaskDelay causes proteus simulation to crash

Hi, It’s my first time using free rtos, and I got a problem while trying to run my tasks with vTaskDelay inside it, when i comment vTaskDelay() from the tasks I get no errors and it works, and when I get the vTaskDelay back to the code proteus pauses,


after i hit continue it crashes saying “can’t fetch op code 0x61000000”
here is the whole project i made in cube ide in a github repo
/T1t4n25/Traffic-light

We need to isolate the problematic part. Start by just creating 2 tasks which do nothing but increment a counter and call vTaskDelay:

void Task( void * params )
{
    uint32_t counter = 0;

    for( ;; )
    {
        counter++;
        vTaskDelay( pdMS_TO_TICKS( 1000 ) );
    }
}

Once that works, you can add parts of your application logic one by one. This will help us narrow down the problematic part.

Sorry I think I deleted a section by accident while writing the post, now it’s edited to the right context, when I comment vTaskDelay the code works, when I get it back the problem appears

Is it also true for the task code snippet I shared? In other words, if you create 2 task with the task function set to the above definition, does it still crash?

1 Like

yes it does crash any usage of vTaskDelay crashes the program

Could you put a break point at the vTaskDelay call and step through it. There is going to be a lot of things going on but the important one is that you should see the task transition to the ‘Blocked’ state (this is done through placing the task on a delayed list) and that the next highest priority task in turn executes. If you try this with only a single application task, rather than two, this will be the IDLE task which gets automatically created.

I can’t debug using a debugger because I don’t have one yet, and proteus just crashes when you use .elf file which supports debugging, so I have no means of doing this, however, I tried one task only and got the same issue, it seems to get to vTaskDelay and crashes, because it never transitioned from green led to any other, nor using the 7 segment only made the counter count anything, just reaches vTaskDelay and stops

Nothing seems wrong with your code at a glance. So we need to isolate if the problem is with your simulation tool or the code itself? Is it possible for you to create a simulation for another hardware? The reason I ask if because I have NUCLEO-H743ZI2 board from ST and if you can create a simulation project for that, then we can see if I can run the same code on the real hardware or not.