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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

662 Views
nikhilmoray
Contributor II

// 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;

  } stBRK_NW_ETH_TIMER_T;

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

  u16EthTimerTicks++;

}

//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

    _time_get_elapsed_ticks(&stBrkNwEthTimer.stTickTimeStart);            

   

    // 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,  

                                                       NULL,                         

                                                       TIMER_ELAPSED_TIME_MODE,    

                                                       &stBrkNwEthTimer.stTickTimeStart,

                                                       &stBrkNwEthTimer.stTickTimeWait

                                                      );

    // 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.

    }

    else

    {

      // Do Nothing

    }

    }

   

  }

  else

  {

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

  }

}

0 Kudos
2 Replies

286 Views
nikhilmoray
Contributor II

Moreover, timer is initializing properly by returning 1 as a timer task id. But after that the execution flow is not going inside the timer function which I have passed as a argument to one of the timer API.

ETH_TIMER_TASK_PRIORITY = 3

ETH_TIMER_STACK_SIZE = 1000

Kindly suggest me any solution over the same.

0 Kudos

286 Views
danielchen
NXP TechSupport
NXP TechSupport

I suggest you check the ETH_TIMER_STRUCT, what is the difference between ETH_TIMER_STRUCT  and  MQX_TICK_STRUCT? I think you can change it to MQX_TICK_STRUCT and try it again.

0 Kudos