AnsweredAssumed Answered

Starting a periodic timer from an ISR?

Question asked by panpwr on Dec 2, 2014
Latest reply on Dec 4, 2014 by David E Seymour

I am trying to use _timer_start_periodic_every() from within ISR (when a button is pressed), but receives results of TIMER_NULL_ID.

When I am debugging into the function, when reaching _timer_start_periodic_every_internal(), this function always reaches following condition and returns MQX_INVALID_LWSEM error:

    /* Gain exclusive access to the timer queues */
    if (kernel_data->ACTIVE_PTR != timer_component_ptr->TIMER_TD_PTR)
    {
        if (_lwsem_wait(&timer_component_ptr->TIMER_ENTRIES_LWSEM) != MQX_OK)
        {
            _task_set_error(MQX_INVALID_LWSEM);
            return(TIMER_NULL_ID);
        } /* Endif */
    } /* Endif */



 

According to the MQX user's guide,  _timer_start_ functions are not included in "Functions That the ISR Cannot Call" - so it should succeed.

However, from the implementation above, I can see that it calls _lwsem_wait() which is not allowed in an ISR.

 

So, my questions:

1. Why can't I allocate a timer from the ISR?

2. If it is because of the lwsem_wait() usage - then why it is still allowed to use?

 

Thanks,

Lior.

Outcomes