This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use NHET implement a timer?

Other Parts Discussed in Thread: RM48L952

The CPU is RM48L952

Because we were asked not to use interrupts, so we can't use RTI for timer.

I think CNT instruction probably should be used for timer, but I don't know well how to implement NHET for timer like executing a function every 100ms ?

Could you give me some advice for this ?

  • You can use CNT as a timer, but in the end it would still just be generating an interrupt when the timer goes off.

    Why were you asked not to use interrupts?
    Are you running an RTOS?
  • Thanks David,

    I think that you could use either approach in the 'infinite loop' alternative to an RTOS (ex. http://www.freertos.org/tutorial/solution1.html)
    and just guard the beginning of the loop with a polling of the status flag in the timer.

    This would mean that no matter how long the loop actually takes to execute, it would execute at most once every timer 'tick'. This is actually the way that the N2HET works by the way ... you branch back to address 0 after executing your N2HET code and then the N2HET pauses until the start of the next loop resolution period before it takes up executing again. This is done to give regular timing to an otherwise variable length N2HET program.

    Seems like there is another good discussion here: http://embeddedgurus.com/state-space/2012/05/superloop-vs-event-driven-framework/
    although I don't have direct experience w. QP.
  • Our client's development rules that interrupt shouldn't be used in programs, so I want to find ways to implement a timer.
    and thank you !
  • Thank you for helping.
    We didn't run OS in RM48, I will discuss this question with my collegues
  • We're using freeRTOS and I've been pretty happy with it. It implements timers as tasks basically, so that would satisfy your requirement of not using interrupts.