EmbeddedRelated.com
Forums

interrupts

Started by Ankur Khetrapal December 28, 2006
Hello

I am using gnuarm compiler with keil.

I need to run a timer interrupt after a specific time interval. I initiate
the timer to generate the interrupt.
void timer_init(void)
{
T0PR = 0x00000C35; //set prescaler = 3125 = 0xC35
T0TCR = 0x00000002; //reset timer counter and prescaler reg
T0CCR = 0x00000005; //rising edge

VICVectAddr0 = (unsigned long)TMR0ISR; //timer0isr vector address
VICVectCntl0 = 0x20 | 4;
VICIntEnable = 0x00000010; //enable interrupt
}

void TMR0ISR(void) __irq
{

// code here
}

but the compiler does not compile the code and i get the error

error: expected declaration specifiers before '__irq'

how do i set the timer interrupt..

am sorry if its too basic a problem. still help needed.

An Engineer's Guide to the LPC2100 Series

Ankur Khetrapal wrote:
>
> Hello
>
> I am using gnuarm compiler with keil.
>
> I need to run a timer interrupt after a specific time interval. I initiate
> the timer to generate the interrupt.
>
> void timer_init(void)
> {
> T0PR = 0x00000C35; //set prescaler = 3125 = 0xC35
> T0TCR = 0x00000002; //reset timer counter and prescaler reg
> T0CCR = 0x00000005; //rising edge
>
> VICVectAddr0 = (unsigned long)TMR0ISR; //timer0isr vector address
> VICVectCntl0 = 0x20 | 4;
> VICIntEnable = 0x00000010; //enable interrupt
> }
>
> void TMR0ISR(void) __irq
> {
>
> // code here
> }
>
> but the compiler does not compile the code and i get the error
>
> error: expected declaration specifiers before '__irq'
>

Exactly, what it says...

Try this:

void TMR0ISR (void) __attribute__((interrupt));

void TMR0ISR(void)
{// blah blah
blah();
for (blah; blah blah; blah) {
...
...
...
You have to throw the kiel syntax away and use the gcc syntax.

TomW
--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net http://cyberiansoftware.com http://openzipit.org
"Windows? No thanks, I have work to do..."
----------------