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);
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!