4.8.1.2 Writing ISRs for a Compact Vector Table
If your project is using a compact vector table, the guidelines discussed for full vector table ISRs also apply; however, note the following differences.
Use the -mcvt
option to inform the compiler that your program will use the compact vector table. By default, this feature is disabled. This option will set the appropriate SFR bits in the runtime startup code, as well as set up the vector table in the .vectors
section.
Write one ISR for each of the non-maskable, Priority Level 1, and Priority Level 0 interrupts, as required by your program. There can be at most three ISRs. If the ISR for the level 0 interrupts is handling multiple interrupt sources, it must check the relevant interrupt flags to see which source has triggered the interrupt. For example:
#Include <avr/interrupt.h>
void __interrupt(CVT_NMI_vect_num) {
// process the NMI here
}
void __interrupt (CVT_LVL1_vect_num) {
// process the level 1 interrupt
}
void __interrupt (CVT_LVL0_vect_num) {
if (PORTA.INTFLAGS & 0x1) {
// process PORTA bit #0 change of state here
}
// process all other level 0 interrupts here
}
When enabled, this feature will define a preprocessor macro called __AVR_COMPACT_VECTOR_TABLE__
, which can be used to conditionally include interrupt fucntions into the program.
On devices supporting CVT, this feature will also be enabled if -mno-interrupts
is specified. This flag can also be used to reduce context-saving code in prologue/epilogue in certain architectures, but it will enable compact vector table support as well.