I had some trobles with the macro pdMS_TO_TICKS (…) - Port MSP430:
(configTICK_RATE_HZ = 2000)
pdMS_TO_TICKS (3333) = 46
The reason is parenthes in the macro.
TickType_t for MSP430 is uint16_t
The macro in projdefs.h is: #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) )
so as for the macro 3333 * 2000 = 6666000 = 0x65b710, for TickType_t it is 0xb710 = 46864
46864 / 1000 = 46
I changed of the parenthes and all is Ok: #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( TickType_t ) ( xTimeInMs ) * ( ( TickType_t ) configTICK_RATE_HZ / ( TickType_t ) 1000U ) ) )
Your change works well when configTICK_RATE_HZ is a whole multiple of 1000. However, if configTICK_RATE_HZ were 500, your change wouldn’t work well because (TickType_t)(500) / (TickType_t)(1000) is zero.
How about using an intermediate 32-bit value, like this:
For an MSP430 project with 16-bit ticks, the 32-bit implementation might best after all. It covers all possible tick counts (0 through 65535). And if there are cases where the delay is calculated at run time, then the minimal work is done (32-bit math instead of 64).