This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nested Interrupts

Hello all,
i use the RealView Compiler but by Compiling the lower C-Code the Compiler reports:
error: #20: identifier "LR" is undefined
error: #20: identifier "SP" is undefined

Thank you for your help
=================================================
/*****************************************************/
/*This file is create using Keil uVision/ARM and the /*Keil CA ARM Compiler */
/*Copyright KEIL ELEKTRONIK GmbH 2004
/* */
/*****************************************************

#include <LPC21xx.H> /* LPC21xx definitions */

int volatile intrp_count = 0;
int volatile timeval = 0;
int volatile SecondCnt = 0;

// Macros for Interrupt Nesting
#define IENABLE /* Nested Interrupts Entry */

__asm { MRS LR, SPSR } \

__asm { STMFD SP!, {LR} } \

__asm { MSR CPSR_c, #0x1F } \

__asm { STMFD SP!, {LR} } \

#define IDISABLE /* Nested Interrupts Exit */ \

__asm { LDMFD SP!, {LR} } /* RestorLR */ \

__asm { MSR CPSR_c, #0x92 } \

__asm { LDMFD SP!, {LR} } \

__asm { MSR SPSR_cxsf, LR } \

/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */

void tc0 (void) __irq {

++timeval;

if ((timeval % 10000) == 0) {

timeval = 0;

SecondCnt++;

}

T0IR = 1; // Clear interrupt flag

VICVectAddr = 0; // Acknowledge Interrupt

}

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {

T0MR0 = 1499; // 0.1mSec = 1.500-1 counts

T0MCR = 3; // Interrupt and Reset on MR0

T0TCR = 1; // Timer0 Enable

VICVectAddr0 = (unsigned long)tc0;

VICVectCntl0 = 0x20 | 4;

VICIntEnable = 0x00000010; // Enable Timer0 Interrupt

}

/* Create a long time delay */

void delay (void) {

int i;

for (i = 0; i < 0x50000; i++) {

;

}

/* External Interrupt 1 Service */

void eint1_srv (void) __irq {

int i;

EXTINT = 2; // Clear EINT1 interrupt flag

IENABLE; // allow nested interrupts

delay (); // wait a long time

++intrp_count; // increment interrupt count

IDISABLE; // disable interrupt nesting

VICVectAddr = 0; // Acknowledge Interrupt

}

/* Initialize EINT1 Interrupt Pin */

void init_eint1 (void) {

EXTMODE = 2;// Edge sensitive modeonEINT1

EXTPOLAR = 2;// raising edge sensitive

PINSEL0 = 2 << 28;// Enable EINT1 on

VICVectAddr1 = (unsigned long) eint1_srv;

VICVectCntl1 = 0x21 | 15;

VICIntEnable = 1 << 15;// Enable EINT1 Interrupt

}

int main (void) {

unsigned int LED_out = 0;

IODIR1 = 0xFF0000;

init_eint1(); // Enable EINT1

init_timer ();

while (1) {

if ((intrp_count & 0xFF) != LED_out) { // intrp_count has changed

LED_out = (intrp_count & 0x7F);

IOCLR1 = 0x7F0000;

IOSET1 = (LED_out << 16);

}

if ((SecondCnt & 1) == 0) IOCLR1 = 0x800000;

else IOSET1 = 0x800000;

}
} Thanks

0