EmbeddedRelated.com
Forums

Problem with entering ISR

Started by federr65 May 29, 2006
I'm just starting with LPC ( I have a LPC-H2138 board from Olicom) and
at the beginning I'm unable to solve the following problem:
I have an Timer0 set to generate interrupts. Timer works just fine,
but I can't force the ISR to execute.
Below is my code:

#include

#define LED 0xF0000000;

static int timer0Count, timer1Count;
int marker=1;
static void PLL_Init(void)
{
PLLCON=0x00000003; //Kwarc razy 4
PLLCFG = 0x23;
PLLFEED = 0xAA;
PLLFEED = 0x55;
}

void inititate (void)
{
//PLL_Init();
//MAMCR = 2;
IO0PIN=0x0;
IO1PIN=0x0;
IO0DIR = 0xFFFFFFFF;
IO1DIR = 0xFFFFFFFF;
}

static void timer0ISR(void) __attribute__ ((interrupt ("IRQ")));

static void timer0ISR(void)
{
if (IO0PIN=0)
{
IO0SET=LED;
}
else
{
IO0CLR=0;
}
/* Clear the timer 0 interrupt */
T0IR = 0xFF;
/* Update VIC priorities */
VICVectAddr = 0;
marker++;
}


int main(void)
{
inititate();

// Timer 0 interrupt is an IRQ interrupt, none is FIQ */
VICIntSelect =0x0;
/* Clear all IRQ and Enable timer 0 interrupt */
VICIntEnClr = 0xFFFFFFFF;
VICIntEnable = 0x10;
/* Use slot 0 for timer 0 interrupt and enable it (bit5)*/
VICVectCntl0 = 0x24;
/* Set the address of ISR for slot 0 */
VICVectAddr0 = (unsigned int)timer0ISR;
/* Match 0 reset - moe nie bykonieczne do dziaania*/
T0IR = 0x1;
/* Reset and stop timer 0 */
T0TCR = 0x2;
/* Set the timer 0 prescale counter */
T0PR = 0x0;
/* Set timer 0 match register */
/* Set timer 0 match register */
T0MR0 = 0xffff;
/* Generate interrupt and reset counter on match */
T0MCR = 0x3;
/* Start timer 0 */
T0TCR = 1;

/* Enable Interrupts */
// __ARMLIB_enableIRQ();
while(1);
}






An Engineer's Guide to the LPC2100 Series

Hi,

try enabling the interrupt by removing the two slashes at calling the
function __ARMLIB_enableIRQ()...

--- In l..., "federr65" wrote:
>
> I'm just starting with LPC ( I have a LPC-H2138 board from Olicom) and
> at the beginning I'm unable to solve the following problem:
> I have an Timer0 set to generate interrupts. Timer works just fine,
> but I can't force the ISR to execute.
> Below is my code:
>
> #include
>
> #define LED 0xF0000000;
>
> static int timer0Count, timer1Count;
> int marker=1;
>
>
> static void PLL_Init(void)
> {
> PLLCON=0x00000003; //Kwarc razy 4
> PLLCFG = 0x23;
> PLLFEED = 0xAA;
> PLLFEED = 0x55;
> }
>
> void inititate (void)
> {
> //PLL_Init();
> //MAMCR = 2;
> IO0PIN=0x0;
> IO1PIN=0x0;
> IO0DIR = 0xFFFFFFFF;
> IO1DIR = 0xFFFFFFFF;
> }
>
>
>
> static void timer0ISR(void) __attribute__ ((interrupt ("IRQ")));
>
> static void timer0ISR(void)
> {
> if (IO0PIN=0)
> {
> IO0SET=LED;
> }
> else
> {
> IO0CLR=0;
> }
> /* Clear the timer 0 interrupt */
> T0IR = 0xFF;
> /* Update VIC priorities */
> VICVectAddr = 0;
> marker++;
> }
>
>
> int main(void)
> {
> inititate();
>
> // Timer 0 interrupt is an IRQ interrupt, none is FIQ */
> VICIntSelect =0x0;
> /* Clear all IRQ and Enable timer 0 interrupt */
> VICIntEnClr = 0xFFFFFFFF;
> VICIntEnable = 0x10;
> /* Use slot 0 for timer 0 interrupt and enable it (bit5)*/
> VICVectCntl0 = 0x24;
> /* Set the address of ISR for slot 0 */
> VICVectAddr0 = (unsigned int)timer0ISR;
> /* Match 0 reset - moe nie bykonieczne do dziaania*/
> T0IR = 0x1;
> /* Reset and stop timer 0 */
> T0TCR = 0x2;
> /* Set the timer 0 prescale counter */
> T0PR = 0x0;
> /* Set timer 0 match register */
> /* Set timer 0 match register */
> T0MR0 = 0xffff;
> /* Generate interrupt and reset counter on match */
> T0MCR = 0x3;
> /* Start timer 0 */
> T0TCR = 1;
>
> /* Enable Interrupts */
> // __ARMLIB_enableIRQ();
>
>
> while(1);
> }
>





> ----- Original Message -----
> From: willem_zx6r
> To: l...
> Sent: Monday, May 29, 2006 2:55 PM
> Subject: [lpc2000] Re: Problem with entering ISR
> Hi,
>
> try enabling the interrupt by removing the two slashes at calling the
> function __ARMLIB_enableIRQ()...

Tried that already. Doesn't work :/

> static void timer0ISR(void)
> {
> if (IO0PIN=0)
> {
> IO0SET=LED;
> }
> else
Also, did you mean to have the single equals sign in the if
statement instead of == ? ... if (IO0PIN=0)

boB

--- In l..., "willem_zx6r" wrote:
>
> Hi,
>
> try enabling the interrupt by removing the two slashes at calling
the
> function __ARMLIB_enableIRQ()...
>
> --- In l..., "federr65" wrote:
> >
> > I'm just starting with LPC ( I have a LPC-H2138 board from
Olicom) and
> > at the beginning I'm unable to solve the following problem:
> > I have an Timer0 set to generate interrupts. Timer works just
fine,
> > but I can't force the ISR to execute.
> > Below is my code:
> >
> > #include
> >
> > #define LED 0xF0000000;
> >
> > static int timer0Count, timer1Count;
> > int marker=1;
> >
> >
> > static void PLL_Init(void)
> > {
> > PLLCON=0x00000003; //Kwarc razy 4
> > PLLCFG = 0x23;
> > PLLFEED = 0xAA;
> > PLLFEED = 0x55;
> > }
> >
> > void inititate (void)
> > {
> > //PLL_Init();
> > //MAMCR = 2;
> > IO0PIN=0x0;
> > IO1PIN=0x0;
> > IO0DIR = 0xFFFFFFFF;
> > IO1DIR = 0xFFFFFFFF;
> > }
> >
> >
> >
> > static void timer0ISR(void) __attribute__ ((interrupt ("IRQ")));
> >
> > static void timer0ISR(void)
> > {
> > if (IO0PIN=0)
> > {
> > IO0SET=LED;
> > }
> > else
> > {
> > IO0CLR=0;
> > }
> > /* Clear the timer 0 interrupt */
> > T0IR = 0xFF;
> > /* Update VIC priorities */
> > VICVectAddr = 0;
> > marker++;
> > }
> >
> >
> > int main(void)
> > {
> > inititate();
> >
> > // Timer 0 interrupt is an IRQ interrupt, none is FIQ */
> > VICIntSelect =0x0;
> > /* Clear all IRQ and Enable timer 0 interrupt */
> > VICIntEnClr = 0xFFFFFFFF;
> > VICIntEnable = 0x10;
> > /* Use slot 0 for timer 0 interrupt and enable it (bit5)*/
> > VICVectCntl0 = 0x24;
> > /* Set the address of ISR for slot 0 */
> > VICVectAddr0 = (unsigned int)timer0ISR;
> > /* Match 0 reset - moe nie bykonieczne do dziaania*/
> > T0IR = 0x1;
> > /* Reset and stop timer 0 */
> > T0TCR = 0x2;
> > /* Set the timer 0 prescale counter */
> > T0PR = 0x0;
> > /* Set timer 0 match register */
> > /* Set timer 0 match register */
> > T0MR0 = 0xffff;
> > /* Generate interrupt and reset counter on match */
> > T0MCR = 0x3;
> > /* Start timer 0 */
> > T0TCR = 1;
> >
> > /* Enable Interrupts */
> > // __ARMLIB_enableIRQ();
> >
> >
> > while(1);
> > }
>





> static void timer0ISR(void)
> {
> if (IO0PIN=0)
> {
> IO0SET=LED;
> }
> else
Also, did you mean to have the single equals sign in the if
statement instead of == ? ... if (IO0PIN=0)

boB

--- In l..., "willem_zx6r" wrote:
>
> Hi,
>
> try enabling the interrupt by removing the two slashes at calling
the
> function __ARMLIB_enableIRQ()...
>
> --- In l..., "federr65" wrote:
> >
> > I'm just starting with LPC ( I have a LPC-H2138 board from
Olicom) and
> > at the beginning I'm unable to solve the following problem:
> > I have an Timer0 set to generate interrupts. Timer works just
fine,
> > but I can't force the ISR to execute.
> > Below is my code:
> >
> > #include
> >
> > #define LED 0xF0000000;
> >
> > static int timer0Count, timer1Count;
> > int marker=1;
> >
> >
> > static void PLL_Init(void)
> > {
> > PLLCON=0x00000003; //Kwarc razy 4
> > PLLCFG = 0x23;
> > PLLFEED = 0xAA;
> > PLLFEED = 0x55;
> > }
> >
> > void inititate (void)
> > {
> > //PLL_Init();
> > //MAMCR = 2;
> > IO0PIN=0x0;
> > IO1PIN=0x0;
> > IO0DIR = 0xFFFFFFFF;
> > IO1DIR = 0xFFFFFFFF;
> > }
> >
> >
> >
> > static void timer0ISR(void) __attribute__ ((interrupt ("IRQ")));
> >
> > static void timer0ISR(void)
> > {
> > if (IO0PIN=0)
> > {
> > IO0SET=LED;
> > }
> > else
> > {
> > IO0CLR=0;
> > }
> > /* Clear the timer 0 interrupt */
> > T0IR = 0xFF;
> > /* Update VIC priorities */
> > VICVectAddr = 0;
> > marker++;
> > }
> >
> >
> > int main(void)
> > {
> > inititate();
> >
> > // Timer 0 interrupt is an IRQ interrupt, none is FIQ */
> > VICIntSelect =0x0;
> > /* Clear all IRQ and Enable timer 0 interrupt */
> > VICIntEnClr = 0xFFFFFFFF;
> > VICIntEnable = 0x10;
> > /* Use slot 0 for timer 0 interrupt and enable it (bit5)*/
> > VICVectCntl0 = 0x24;
> > /* Set the address of ISR for slot 0 */
> > VICVectAddr0 = (unsigned int)timer0ISR;
> > /* Match 0 reset - moe nie bykonieczne do dziaania*/
> > T0IR = 0x1;
> > /* Reset and stop timer 0 */
> > T0TCR = 0x2;
> > /* Set the timer 0 prescale counter */
> > T0PR = 0x0;
> > /* Set timer 0 match register */
> > /* Set timer 0 match register */
> > T0MR0 = 0xffff;
> > /* Generate interrupt and reset counter on match */
> > T0MCR = 0x3;
> > /* Start timer 0 */
> > T0TCR = 1;
> >
> > /* Enable Interrupts */
> > // __ARMLIB_enableIRQ();
> >
> >
> > while(1);
> > }
>





--- In l..., "bobtransformer" wrote:
>
>
> > static void timer0ISR(void)
> > {
> > if (IO0PIN=0)
> > {
> > IO0SET=LED;
> > }
> > else
>
>
> Also, did you mean to have the single equals sign in the if
> statement instead of == ? ... if (IO0PIN=0)

I deleted the "=" mark accidentally while formatting the text for posting.
Some more info that I didn't included in my first post:
1. I'm using Crossworks 1.5
2. After Timer match registers are in following states:
VICIrqStatus: 0x00000010
VICRawIntr: 0x00002018

It looks like VICVectorAddr0 is not pointing to the ISR. I tried
adding #define VECTORED_IRQ_INTERRUPTS ; and replacing code in startup.s:

#ifdef VECTORED_IRQ_INTERRUPTS
.word 0xB9205F84 /* boot loader checksum */
ldr pc, [pc, #-0xFF0] /* irq handler */
#else
.word 0xB8A06F60 /* boot loader checksum */
ldr pc, [pc, #irq_handler_address - . - 8] /* irq handler */
to:
#ifdef VECTORED_IRQ_INTERRUPTS
.word 0xB9205F84 /* boot loader checksum */
ldr pc, [pc, #-0xFF0] /* irq handler */
#else
.word 0xB8A06F60 /* boot loader checksum */
ldr pc, [pc, #-0xFF0] /* irq handler */

But it didn't work either.
Thanks for your attention.





> static void timer0ISR(void) __attribute__
> ((interrupt ("IRQ")));
>
> static void timer0ISR(void)
> {
> if (IO0PIN=0)
> {
> IO0SET=LED;
> }
> else
> {
> IO0CLR=0;

Is this some typing error ???
Should be:

IO0CLR = LED;

Also try adding a default ISR or write this:

VICDefVectAddr = (unsigned long)timer0ISR;

And see what happens.

Regards
Zdravko

Знанието е лично преживяна истина.

__________________________________________________

>
> Is this some typing error ???
> Should be:
>
> IO0CLR = LED;
>

Yes, it is.

> Also try adding a default ISR or write this:
>
> VICDefVectAddr = (unsigned long)timer0ISR;
>
> And see what happens.

I added this line, I also tried adding:
VICVectAddr = (unsigned long)timer0ISR;
But it didn't work also.
Best Regards
Peter