Forums

crossstudio & timer interrupt

Started by windam_2000 February 16, 2007
Hello All,

I'm trying to setup a timer interrupt for Timer0. I have a Keil 2130
board with a LPC2138. I set a breakpoint at timer interrupt function,
but it doesn't get there. I see the timer count register
incrementing, so the timer is ok. I checked the VIC and the address
and interrupt is enabled.

Except for startup.s, the same code works with uVision + GCC/ARM. So
I think I'm missing something in my Cross Studio environment.

Just to make sure that the interrupt vector are installed properly, I
modified startup.s supplied with the LPC2100 and Keil 2130 packages:
_vectors:
ldr pc, [pc, #reset_handler_address - . - 8] /* reset */
ldr pc, [pc, #undef_handler_address - . - 8] /* undefined
instruction */
ldr pc, [pc, #swi_handler_address - . - 8] /* swi handler */
ldr pc, [pc, #pabort_handler_address - . - 8] /* abort prefetch */
ldr pc, [pc, #dabort_handler_address - . - 8] /* abort data */
/* #ifdef VECTORED_IRQ_INTERRUPTS */
.word 0xB9205F88 /* boot loader checksum */
ldr pc, [pc, #-0xFF0] /* irq handler */
ldr pc, [pc, #fiq_handler_address - . - 8] /* fiq handler */

--- My timer setup:
void tc0 (void) __attribute__ ((interrupt)); // Generate Interrupt

/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 149999; // 10mSec = 150.000-1
counts
T0MCR = 3; // Interrupt and Reset
on MR0
T0TCR = 1; // Timer0 Enable
VICVectAddr0 = (unsigned long)tc0; // set interrupt
vector in 0
VICVectCntl0 = 0x20 | 4; // use it for Timer 0
Interrupt
VICIntEnable = 0x00000010; // Enable Timer0 Interrupt
}

/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
void tc0 (void) {
timeval++;
T0IR = 1; // Clear interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt
}

Any suggestions would be appreciated.

Thanks,

-win

An Engineer's Guide to the LPC2100 Series