Hardware Reference
In-Depth Information
source and is represented by the name of the interrupt service routine. One way to set up the
interrupt vector in ICC12 when working with a demo board programmed with the D-Bug12
monitor is to use the inline assembly instructions.
asm(“ldd #_rtiISR”);
// push address of RTI interrupt service routine
asm(“pshd”);
//
asm(“ldd #56”);
// place vector number of RTI in D
asm(“ldx $EEA4”);
// place the SetUserVector function address in X
asm(“jsr 0,X”);
// jump to SetUserVector function to set up RTI
// interrupt vector (in SRAM)
6.5.3 Interrupt Programming in EGNU IDE
In the EGNU IDE, we must take the following actions in order to use interrupts:
1. Use the interrupt attribute of the GCC compiler . We must include the following
statement as one of the first few statements in the program (there are two ' _ '
characters before and after “attribute”):
#define INTERRUPT __attribute__((interrupt))
2. Apply the interrupt attribute to the interrupt service routine . Assuming that rtiISR()
and oc5ISR() are two interrupt service routines, then we add the following two
prototype declaration statements (for rtiISR() and oc5ISR() ) in the program:
void INTERRUPT rtiISR(void);
void INTERRUPT oc5ISR(void);
3. Include the vectors12.h header file so that one can use mnemonic names to store the
starting addresses of interrupt service routines in the vector table (in SRAM). Include
the following statements as one of the first few statements in the program:
#include “c:\egnu\include\vectors12.h”
4. Store interrupt vectors in the SRAM vector table . This can be done by assignment
statements.
UserRTI 5 (unsigned short)&rtiISR;
UserTimerCh5 5 (unsigned short)&oc5ISR;
5. Write the actual interrupt service routine .
The C language version of the IRQ interrupt program given in Example 6.1 is as follows:
#include
“c:\egnu\include\hcs12.h”
#include
“c:\egnu\include\vectors12.h”
#define
INTERRUPT __attribute__((interrupt))
void
INTERRUPT IRQISR(void);
unsigned char cnt;
void main(void)
{
UserIRQ
5 (unsigned short)&IRQISR;
DDRB
5 0xFF;
// configure Port B for output
cnt
5 0;
DDRJ
| 5 BIT1;
// configure PJ1 pin for output
PTJ
& 5 , BIT1;
// enable LEDs to light (required for Dragon12 demo board)
IRQCR
5 0xC0;
// enable IRQ interrupt on falling edge
 
Search WWH ::




Custom Search