I have a project that was using HWI interrupts without ECM that I have been trying to modify to use the ECM. Without ECM, it hooked INT4 and INT5 to the UART and RTC:
bios.HWI.instance("HWI_INT4").interruptSelectNumber = 69;
bios.HWI.instance("HWI_INT4").fxn = prog.extern("UART2_Interrupt");
bios.HWI.instance("HWI_INT4").useDispatcher = 1;
bios.HWI.instance("HWI_INT5").interruptSelectNumber = 63;
bios.HWI.instance("HWI_INT5").fxn = prog.extern("RTC_Interrupt");
bios.HWI.instance("HWI_INT5").useDispatcher = 1;
The main() function initializes the clock, pins, and enables HWI INT4 & 5 through:
C64_enableIER(C64_EINT4 | C64_EINT5).
I commented out the HWI code above, and turned on the ECM:
bios.ECM.ENABLE = 1;
bios.HWI.instance("HWI_INT7").interruptSelectNumber = 0;
bios.HWI.instance("HWI_INT8").interruptSelectNumber = 1;
bios.HWI.instance("HWI_INT9").interruptSelectNumber = 2;
bios.HWI.instance("HWI_INT10").interruptSelectNumber = 3;
bios.ECM.instance("EVENT63").unmask = 1;
bios.ECM.instance("EVENT63").fxn = prog.extern("RTC_Interrupt");
bios.ECM.instance("EVENT69").unmask = 1;
bios.ECM.instance("EVENT69").fxn = prog.extern("UART2_Interrupt");
In main, the IER enable changed to:
C64_enableIER(C64_EINT7 | C64_EINT8 | C64_EINT9 | C64_EINT10).
The UART interrupts through event 69, HWI_INT8 continue to work properly. I no longer get RTC interrupts. I can comment out the ECM event 63 lines and restore RTC on HWI_INT5, and the RTC interrupts come back. Here, I have the UART on ECM and the RTC directly attached.
What am I doing wrong?