I am having a problem with the "CLRINT" and "SETINT" instructions that are recommended to set or clear latched interrupts in the IRPTL register and writing to IRPTL in general.
This is the scenario:
We are using a timer to generate a PWM waveform used to control an external device. This device is very sensitive to any glitches that might occur due to a change in the period or pulsewidth. To allow smooth, glitch-free transitions we have developed a two staged update procedure based on what is described in the hardware reference.
We are using the timers interrupt to facilitate this update, but don't need the interrupt for anything else. Since the system is doing hard real-time control as well, we would like to only enable the timers interrupt when a PWM update is pending.
To this end, the interrupt service routine automatically clears the corresponding mask bit in the IMASK register and the ISR is not called anymore and this works as intended.
When an update is pending, the interrupt has to be unmasked, but the interrupts latch bit is of course set in the IRPTL register due so several PWM periods having passed.
So prior to unmasking the interrupt I planned to:
a) clear the interrupt latch and overflow bits in the timers status register:
iopg = Timer_Page; ax0 = 0x0044; // clear timer2 interrupt and ovfl to avoid re-issued interrupt io(GSR2) = ax0;
b) clear the latched interrupt bit in the IRPTL register:
clrint 13; // clear already latched timer2 interrupt
c) finally unmask the interrupt so it gets triggered after the next period ends:
ar = imask; // enable interrupt ar = setbit 13 of ar; imask = ar;
The problem is, that the "clrint 13" is apparently not doing anything, because the IRPTL register remains unchanged (even several cycles later (it has a 1 cycle write delay).
I also tried clearing all bits by setting "irptl = 0" but this also changes nothing in the register.
Any help would be greatly appreciated, thank you very much in advance!