We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Does using the __irq at the end of the function automatically calls itself when an interrupt occurs? for e.g. void ISR_TIMER0(void) __irq {
int interrupt; //-------------------------- if( T0IR & _MR0 ) { interrupt = _MR0; if(isrT0MR0Handler != NULL) (*isrT0MR0Handler)(); //call Timer0-Match0 handler function } else if( T0IR & _MR1) { interrupt = _MR1; if(isrT0MR1Handler != NULL) (*isrT0MR1Handler)(); //call Timer0-Match1 handler function } else if( T0IR & _MR2) { interrupt = _MR2; if(isrT0MR2Handler != NULL) (*isrT0MR2Handler)(); //call Timer0-Match2 handler function } else if( T0IR & _MR3) { interrupt = _MR3; if(isrT0MR3Handler != NULL) (*isrT0MR3Handler)(); //call Timer0-Match3 handler function } else if( T0IR & _CR0) { interrupt = _CR0; if(isrT0CR0Handler != NULL) (*isrT0CR0Handler)(); //call Timer0-Capture0 handler function } else if( T0IR & _CR1) { interrupt = _CR1; if(*isrT0CR1Handler != NULL) (isrT0CR1Handler)(); //call Timer0-Capture1 handler function } //-------------------------- T0IR |= interrupt; //clear interrrupt //-------------------------- }
This is example of a interrupt function. Tell me the interrupt handler function and when will the function get called?
As far as I know, The __irq is places at the beginning of the line, and just indicates to the compiler that this is a interrupt function. The compiler then adds relevant registers push and pops to handle the interrupt.
The interrupt function is called whenever a hardware event occurs (timer in your example). The timer hardware and interrupt controller have to be set up to enable the interrupt, and to link it to your interrupt function. This depends on the microprocessor you are using (arm7, arm9, cortex...)
Denis