- Fri Jan 16, 2009 12:52 am
#63581
I'm an ARM newb. One at a time I'm going through the peripherals on my LPC-P2148 to learn how ARMs do it (played with HC11/12s, AVRs, MSP430s, lots of PICs before).
I wrote this little test program and can't get the interrupt to fire. I've been over it and over it. Looks right to me (not that that means anything ).
I'm using Eclipse/yagarto.
Can anyone spot what I'm doing wrong here?
I wrote this little test program and can't get the interrupt to fire. I've been over it and over it. Looks right to me (not that that means anything ).
I'm using Eclipse/yagarto.
Can anyone spot what I'm doing wrong here?
Code: Select all
#include "LPC214x.h"
#define PLOCK 0x400
void init(void);
void IRQ_Routine (void) __attribute__ ((interrupt("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
int main(void)
{
IODIR0 = 0x30600000;
IOCLR0 = 0x30600000; //LEDs off
init();
T0MR0 = 0x00001388; //compare-hit count
T0MCR = 0x0003; //interrupt and reset on MR0
T0TCR = 0x01; //enable Timer0
VICVectCntl0 = 0x00000030; //use it for Timer 0 Interrupt:
VICVectAddr0 = (unsigned)IRQ_Routine; //set interrupt vector in 0
VICIntEnable = 0x00000010; //enable TIMER0 interrupt
while(1);
}
void init(void)
{
PLLCFG=0x24; //set multiplier/divider values
PLLFEED=0xaa;
PLLFEED=0x55;
PLLCON=0x01; //enable PLL
PLLFEED=0xaa;
PLLFEED=0x55;
while(!(PLLSTAT & PLOCK)); //wait for the PLL to lock to set frequency
PLLCON=0x3; //connect the PLL as the clock source
PLLFEED=0xaa;
PLLFEED=0x55;
MAMCR=0x02; //enable MAM
MAMTIM=0x04; //set number of clocks for flash memory fetch
VPBDIV=0x01; //set peripheral clock(pclk) to system clock(cclk)
}
void IRQ_Routine(void)
{
IOPIN0 ^= 0x30600000; //toggle 4 LEDs
T0IR = 0x01; //clear interrupt
VICVectAddr0 = 0x00000000; //end of interrupt - dummy write
}
void FIQ_Routine(void){
while (1) ;
}
void SWI_Routine(void){
while (1) ;
}
void UNDEF_Routine(void) {
while (1) ;
}
Last edited by futz on Mon Jan 19, 2009 4:10 pm, edited 1 time in total.
=======================
[url=http://ghmicro.com]Futz's Microcontrollers & Robotics[/url]
=======================
[url=http://ghmicro.com]Futz's Microcontrollers & Robotics[/url]
=======================