I noticed the following behavior in my code using the MQX 3.8 and the K60 BSP -didn't confirm other processors
occasionally the following pair of calls will fail, and the _time_to_date function will return FALSE. Though you wouldn't notice it since most MQX internal calls ignore the _time_to_date function return value. This seems to be the source of a ton of file time stamp glitches I have noticed.
I was using the following code and had to change it, but the problem still exist all over MQX. I will probably patch MQX myself.
_time_get(&time_mqx);
_time_to_date(&time_mqx, &clk_time);
My fix for the snippet was :
_time_get(&time_mqx);
/* Fix for a wonderful little MQX bug*/ |
if (time_mqx.MILLISECONDS ==1000){
time_mqx.MILLISECONDS =0; | |
time_mqx.SECONDS++; |
}
_time_to_date(&time_mqx, &clk_time);
FYI the fix was NOT included in MQX 4.0
FYI: the fix has been applied and will be included in MQX 4.0.1 release.
Any hint as to when 4.0.1 will be released?
Ideally 22.4.2013.
Hi Robert,
you are right. On the other hand there are plans and already some progress in remaking timer concept in MQX.
Hello,
yes, it's not in MQX 4.0 as you stated. This will be fixed but first this bug requires thorough code review and perhaps to rewrite more parts of the code :smileywink:
Regards,
MartinK
Hello Robert,
Thank you for reporting the bug, I will dig into it during this week and I will return here with an outcome.
Regards,
MartinK
Hello,
can you replace function _psp_ticks_to_time in psp_tkti.c and rebuild psp and test this:
boolean _psp_ticks_to_time
(
/* [IN] Pointer to the tick struct to store the results in */
PSP_TICK_STRUCT_PTR tick_ptr,
/* [OUT] Pointer to the time struct to convert */
TIME_STRUCT_PTR time_ptr
)
{ /* Body */
uint_64 tmp, hwt;
uint_32 tps;
KERNEL_DATA_STRUCT_PTR kernel_data;
_GET_KERNEL_DATA(kernel_data);
tps = kernel_data->TICKS_PER_SECOND;
/* Saturate if ticks go out of range of time struct */
if ( (tick_ptr->TICKS[0] / tps) > MAX_UINT_32) {
time_ptr->SECONDS = MAX_UINT_32;
time_ptr->MILLISECONDS = 999;
return FALSE;
} /* Endif */
/* */
tmp = (tick_ptr->TICKS[0] * 1000) + (tick_ptr->HW_TICKS[0] * 1000 / kernel_data->HW_TICKS_PER_TICK);
tmp = tmp / tps;
time_ptr->SECONDS = tmp / 1000;
time_ptr->MILLISECONDS = tmp - time_ptr->SECONDS * 1000;
return TRUE;
} /* Endbody */
Regards,
MartinK
MartinK -- That seems to have fixed the problem for me too. Thanks!
That seemed to solve my problem, without adding any discernible side effects.
Thanks for the help