The attached file demonstrates implementing non-vectored interrupts in assembly for a PIC 18F27K42. For this exercise, Timer1 and Timer3 are configured to run concurrently and each generates an interrupt on rollover. The interrupt service routine (ISR) demonstrates how to: disable additional interrupts during processing the current interrupt; determine which timer generated the interrupt; increment a rollover counter; reset the interrupt flag; re-enable interrupts; and return to the main program. All Timer and interrupt configuration is handled in the main code. The Main code includes a forever loop that toggles indicator LEDs when each timer counter equals a predefined trigger value. I do not code in Assembler, so there are likely better ways to do this. It works for my application, which is measuring time values for a tach measuring RPM from <100 to >11K. References for my approach include Section 6.3 of the PBP3 compiler reference manual; Section 41 Instruction Set Summary of the PIC18F27K42 datasheet; and various internet sources, including discussions on this forum.
Bookmarks