How to get uptime of more then 30 years ?

Hello, I want to know how to get uptime because xTaskGetTickCount() return an 32-bit unsigned int ?… 32-bit is too small. Is there a FreeRTOS function to do it ? Precision time of one second is enought

How to get uptime of more then 30 years ?

First – this is only an application issues – the kernel itself doesn’t care that the timer overflows as that is handled internally. Many applications, especially in the early years, used 16-bits tick values so overflowed very regularly and many of our tests still use 16-bit ticks to force that to happen. Your application code on the other hand would have to handle this by noticing that the tick count value had wrapped, and then act appropriately. There is actually a variable in FreeRTOS/Source/tasks.c called xNumOfOverflows which also counts the number of overflows, but it is static so file scope. The functions vTaskSetTimeoutState() https://freertos.org/vTaskSetTimeOutState.html and xTaskCheckForTimeOut() https://freertos.org/xTaskCheckForTimeOut.html do make use of it though. If you wanted access yourself you could add a ‘get’ function to a header file called freertostaskscadditions.h, and then set configINCLUDEFREERTOSTASKCADDITIONSH to 1 in FreeRTOSConfig.h to have the header file incldued at the bottom of tasks.c. If you look at the code at the bottom of tasks.c you will see the mechanism.

How to get uptime of more then 30 years ?

In addition – you would only need this to have a delay longer than 30 years – otherwise provided you maintain the time in unsigned variables and formulate the tests on the time correctly overflows will result in underflowed comparison results that will actually give you the right answer.