[Coco] Hook an IRQ in CMOC?
Pierre Sarrazin
sarrazip at sarrazip.com
Wed Nov 8 18:46:15 EST 2017
Hi Randy,
Dixit Randy Weaver (2017-11-08 06:51):
> Are their any examples of hooking an IRQ to a CMOC function?
Here is one. First, define the service routine using the "interrupt"
keyword, and use certain ports to test that the IRQ is due to the 60
Hz timer:
interrupt void irqISR()
{
if ((* (char *) 0xFF03) & 0x80) // do nothing if 63.5 us interrupt
{
// 60 Hz interrupt. Reset PIA0, port B interrupt flag.
* (char *) 0xFF02;
// Do something that needs to be done every 60th of a second.
}
}
Then, install that function as the IRQ handler:
#include <coco.h>
[...]
disableInterrupts();
byte *isr = * (byte **) 0xFFF8;
*isr = 0x7E; // JMP extended
* (void **) (isr + 1) = irqISR;
enableInterrupts();
Inline assembly can be used if more efficiency is needed.
This and other topics are covered in the manual:
http://sarrazip.com/dev/cmoc-manual.html
http://sarrazip.com/dev/cmoc.html
--
Pierre Sarrazin <sarrazip @ sarrazip . com>
More information about the Coco
mailing list