Author Topic: di / ei timing  (Read 4472 times)

0 Members and 1 Guest are viewing this topic.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
di / ei timing
« on: July 21, 2019, 12:26:44 pm »
I am using the crystal timers for very precise timekeeping and I want to know if I can disable and enable interrupts for certain small routines without that throwing off the timer.

What does using ei and di to enable and disable interrupts do to the interrupts 'timer'? Does it pause it so that if an interrupt would occur in 1000 t-states before interrupts were disabled, it would actually happen 1000 t-states after they were enabled again or does it happen 1000 - (amount of t-states that interrupts were disabled for) t-states?
Does using the crystal timers vs normal interrupts make any difference?
I'm still around... kind of.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: di / ei timing
« Reply #1 on: July 21, 2019, 12:47:35 pm »
Since you can use the timers without interrupts I'd imagine that they count independent of whether or not interrupts are enabled or disabled. However, if the timer hit 0 without your acknowledging and then you later EI, it looks like it'll immediately trigger an interrupt.

Specifically, I was reading about the timers' loop control ports, but I'm not experienced with the timers yet, so I may have misinterpreted it.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: di / ei timing
« Reply #2 on: July 21, 2019, 03:08:46 pm »
Since you can use the timers without interrupts I'd imagine that they count independent of whether or not interrupts are enabled or disabled. However, if the timer hit 0 without your acknowledging and then you later EI, it looks like it'll immediately trigger an interrupt.

Specifically, I was reading about the timers' loop control ports, but I'm not experienced with the timers yet, so I may have misinterpreted it.
You read it right. I just didn't pay enough attention to that when I was making it. So disabling interrupts only prevents them from occurring. When interrupts are off, they will pile up like when the ISR is too long.

That should be fine then. Thanks
I'm still around... kind of.