jeudi 13 juillet 2023

How does timer interrupts work on TI AM64x

I never used timers for embedded micro controller programming, so there are several things I would like to learn about. I am using the TI AM64x chip and try to understand the example in the AM64x Timer SDK Guide:

TimerP_Params timerParams;
/* setup timer but dont start it */
TimerP_Params_init(&timerParams);
timerParams.inputPreScaler    = 1u;
timerParams.inputClkHz        = 250u*1000u*1000u;
timerParams.periodInUsec      = 10u*1000u;
timerParams.oneshotMode       = 0;
timerParams.enableOverflowInt = 1;
TimerP_setup(timerBaseAddr, &timerParams);

To my understanding the timer can trigger 3 different interrupts (overflow, match, compare). But exactly when and how are these interrupts triggered?

Overflow

  1. Is this triggered after periodInUsec or once the 32bit counter is overflown? I need to trigger an interrupt after a certain time.
  2. If enableOverflowInt is enabled, is the interrupt automatically triggered? How do I capture the interrupt in my code? Or do I need to deal with it manually, like this:
while(true) {
  if(TimerP_isOverflowed(timerBaseAddr)) {
    // do stuff...
  }
  TimerP_clearOverflowInt(timerBaseAddr)
}

Match, Compare

How do I "activate" these interrupts? The timer parameters seem to have no settings for these triggers (like enableOverflowInt). However there is this function TimerP_getCount(timerBaseAddr), but it will return the 32bit counter value. So I need to convert the time value and compare it to the counter value? And I have to do it manually again?

Further information: AM64x User Guide (Chapter 12.5.3 Timers; page 8061).
Thanks a lot for your help!

Aucun commentaire:

Enregistrer un commentaire