AnsweredAssumed Answered

MQX KSDK v1.2.0 TIME_STRUCT Issues

Question asked by jschepler on Oct 31, 2016
Latest reply on Nov 1, 2016 by Daniel Chen

Hello,

 

We are using the following:

  • Processor: K64F
  • IDE: Kinetis Design Studio V3.0
  • KSDK V1.2.0
  • MQX for KSDK V1.2.0

 

We utilize a lot of calls to the _time_get and _time_diff functions, and have a lot of variables (maybe 20?) that are declared as type TIME_STRUCT.  

 

We are seeing strange behavior in logic statements that determine if an elapsed time has been longer than a constant value.  Below is some psuedo code of our current logic:

 

//This code is executed in a task that runs ~ every 200 ms

#define TIME_ELEMENTS 10
#define TIME_DELAY     2
TIME_STRUCT start_time[ TIME_ELEMENTS ] = {0};
TIME_STRUCT end_time[ TIME_ELEMENTS ] = {0};
TIME_STRUCT time_diff[ TIME_ELEMENTS ] = {0};

uint8_t i;
uint8_t response[ TIME_ELEMENTS ] = {0};

bool flag[ TIME_ELEMENTS ] = false;

for(i=0; i<TIME_ELEMENTS; i++)
{
   response[k] = get_external_variable( k );
  
   if(response[k] == 1)
   {
     
     if( flag[k] == false )
     {
        flag[k] = true;
        _time_get(&start_time[k]);
     }
    
     else
     {
        _time_get(&end_time[k]);
        _time_diff(&start_time[k], &end_time[k], &time_diff[k])
     }
    
     if(time_diff[k].SECONDS >= TIME_DELAY)
     {

         // Code should xecute here only after TIME_DELAY,
         // but it jumps here immediately.

     }     

   }
   else
   {
      start_time[k].SECONDS = 0;
      start_time[k].MILLISECONDS = 0;
      time_diff[k].SECONDS = 0;
      time_diff[k].MILLISECONDS = 0;
      end_time[k].SECONDS = 0;
      end_time[k].MILLISECONDS = 0;
      flag[k] = false;

   } // End else

} // End for

 

I searched the forums for some MQX time problems, and found the following post:

 

How to solve MQX RTCS_time_get() problem? 

 

I think they use the RTCS for _get_time, but should be similar to non-RTCS _get_time function call.

 

Does anyone know if the issue they were describing has been resolved in MQX for KSDK v1.2.0?  

Outcomes