AnsweredAssumed Answered

Hi... I have tried to use MQX timer in the following way but it's not working.

Question asked by Nikhil Moray on Sep 11, 2014
Latest reply on Sep 20, 2014 by Daniel Chen

// MQX timer task structure

typedef struct


  // Timer Task id

  _mqx_uint             u32TimerTaskId;


  // MQX tiemr structure instance for getting starting time in ticks

  ETH_TIMER_STRUCT      stTickTimeStart;


//  // MQX tiemr structure instance for getting the waiting time

  ETH_TIMER_STRUCT      stTickTimeWait;





volatile UINT16_T u16EthTimerTicks = ONE;


//This is the function which I want to call after every 50 msec.


static void fnBrkNwEthTimeTickIncrement( _timer_id, pointer,  MQX_TICK_STRUCT_PTR)


  // Increment time ticks for every 1 msec




//Initialization function for MQX timer is as follows.


void fnBrkNwEthTimerInit(void)


  // MQX timer return status

  _mqx_uint u32EthTimerStatus;


  // MQX timer task ID

  _mqx_uint u32EthTimerTaskId;



  // Creates the timer component

  u32EthTimerStatus = _timer_create_component(ETH_TIMER_TASK_PRIORITY,   ETH_TIMER_STACK_SIZE);                                                        


  // Check for timer create component status

  if(u32EthTimerStatus == MQX_OK)


    // Initialize wait time structure

    _time_init_ticks(&stBrkNwEthTimer.stTickTimeWait,  ZERO);                                                    



    // Get the elapsed time



    // Add time in milli second units to tick time

    _time_add_msec_to_ticks(&stBrkNwEthTimer.stTickTimeWait, 50);          


    // Start MQX periodic timer with 1 msec of Time period

    u32EthTimerTaskId = _timer_start_periodic_at_ticks(fnBrkNwEthTimeTickIncrement,  







    // Copy MQX timer task ID

    stBrkNwEthTimer.u32TimerTaskId = u32EthTimerTaskId;


    // Check whether periodic has been properly started

    if(u32EthTimerTaskId != TIMER_NULL_ID)


      // Log critical error: Timer hasn't been started properly.




      // Do Nothing







    // Log critical error: Timer hasn't been initialized properly.