Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Problem with entering ISR

Problem with entering ISR

2006-05-29 by federr65

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 <targets/LPC213x.h>

#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 - mo¿e nie byæ konieczne do dzia³ania*/
  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);
}

Re: Problem with entering ISR

2006-05-29 by willem_zx6r

Hi,

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

--- In lpc2000@yahoogroups.com, "federr65" <feder@...> wrote:
Show quoted textHide quoted text
>
> 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 <targets/LPC213x.h>
> 
> #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 - mo¿e nie byæ konieczne do dzia³ania*/
>   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);
> }
>

Re: [lpc2000] Re: Problem with entering ISR

2006-05-29 by Piotr Fedorowicz

> ----- Original Message ----- 
> From: willem_zx6r 
> To: lpc2000@yahoogroups.com 
> 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 :/

Re: Problem with entering ISR

2006-05-29 by bobtransformer

> 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 lpc2000@yahoogroups.com, "willem_zx6r" <willem@...> wrote:
>
> Hi,
> 
> try enabling the interrupt by removing the two slashes at calling 
the
> function __ARMLIB_enableIRQ()... 
> 
> --- In lpc2000@yahoogroups.com, "federr65" <feder@> 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,
Show quoted textHide quoted text
> > but I can't force the ISR to execute.
> > Below is my code:
> > 
> > #include <targets/LPC213x.h>
> > 
> > #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 - mo¿e nie byæ konieczne do dzia³ania*/
> >   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);
> > }
> >
>

Re: Problem with entering ISR

2006-05-29 by federr65

--- In lpc2000@yahoogroups.com, "bobtransformer" <bgudgel@...> 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.

Re: [lpc2000] Problem with entering ISR

2006-05-30 by 3gpabko

> 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

\u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e \u0435 \u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0430.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

Re: Problem with entering ISR

2006-05-30 by federr65

> 
> 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

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.