Some tasks stop running after some time

Hello, i have created a freeRtos project for s32k142 (cortex m4), and it is working, all the tasks that i have seems to be working, but after some time some of them will not work.
I debugged the task that is not working and it seems like “xTaskGetTickCount” doesn’t give correct tick value

Hi @Zak,
The information seems not enough to provide any suggestion. Could you help to elaborate more about what you’re doing and what you’ve done for debugging?

BTW, are configASSERT and Stack overflow detection enabled in your project?

Thanks.

Hello, here is some detail
okey this is part of my function from the task which is causing the problem

image

so at the beginning the value xTickCountTx will be zero, and it will be incremented by the time. on the other hand “ctx->List[i].timeout” will be incremented by 50 ( 0 → 50 → 100 → 150 → …) whenever this condition “if( xTickCountTx >= ctx->List[i].timeout )” is correct.

once both “xTickCountTx” and “ctx->List[i].timeout” reach 65500 this will happen:
ctx->List[i].timeout = 65550, for all the time.
xTickCountTx will never reach 65550, it will increment slightly and sometimes even decrement to some lower values (35279, 20048, 11570 etc …).

May I know configUSE_16_BIT_TICKS in your FreeRTOS_Config.h and TickType_t in portmacro.h?
It’s possible that xTaskGetTickCount() returns 16 bits so it never reaches 65550.

Thanks.

One thing more to watch out for, unless you can be SURE that this gets run EVERY tick, there is a possibility that the tick counter will just pass your value, so an equality test can be dangerous,

Also, you need to make sure your variables are 32-bit values, as with a 16-bit values 65550 isn’t representable, but is actually just 14 after wrapping.

xTickCountTx is 32-bits, but is the timeout member also 32-bit?

Hello, thank you all for your support, yes it was because of the tick_type is defined as uint16_t