Yahoo Groups archive

Lpc2000

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

Thread

Strange timer problem

Strange timer problem

2005-03-30 by peterburdine

I'm using the Keil's compiler and I'm trying to setup a system clock
that increments every 5ms.  I am doing this by having a unsigned long
int that gets incremented on the timer interrupt.  The timer also
resets when the interrupt occurs.  The problem is this seems to
somehow corrupt a few registers every once in a while and will
generally end up in a data abort.  I believe the timer must be the
cause because if I remove it, I no longer have these problems. 

I'd appreciate any suggestions.

The applicable code is listed here:

unsigned long int getTickCounter (void);
void T0_ISR (void) __arm __fiq;
unsigned long int tickCount = 0;



	T0MR0 = PCLK/200; // Every 50ms
	T0IR = 0xF;	// Clear Interrupts on MR0	
	T0MCR = 0x03;  // Reset and Interrupt on MR0
	VICIntEnable = 1 << 4;
	VICVectAddr3 = (unsigned long)T0_ISR;
	VICVectCntl3 = 0x20 | 4;
	T0TCR = 0x2;	// Reset the timer
	T0TCR = 0x1;	// Start the timer


void T0_ISR(void) __arm __fiq {
	tickCount++;

	// Clear Interrupts
	VICVectAddr = 0;
	T0IR = 0x1;	
}


This is a very useful function!
void DAbt_Handler(void) __arm __irq {
	Uint32 i;	
	// Grab the return address (location where mem access failed)
	__asm	{STAV R14, R0, i};
	printf("*****Data abort occured 0x%x *****", i);
	// Now just spin
	while(1);
}

Re: Strange timer problem

2005-03-30 by peterburdine

I figured it out.  It didn't work as and irq, so I switched it to fiq
and added VICIntSelect = 1<<4; and it seems to work just fine now. 
Although I wonder why it didn't work as an irq.  And yes I know that
when the msg was first posted I had __fiq on the ISR, that was my
halfway between code, I had __irq on them originally.

--Peter

--- In lpc2000@yahoogroups.com, "peterburdine" <lordofdawn@h...> wrote:
Show quoted textHide quoted text
> 
> I'm using the Keil's compiler and I'm trying to setup a system clock
> that increments every 5ms.  I am doing this by having a unsigned long
> int that gets incremented on the timer interrupt.  The timer also
> resets when the interrupt occurs.  The problem is this seems to
> somehow corrupt a few registers every once in a while and will
> generally end up in a data abort.  I believe the timer must be the
> cause because if I remove it, I no longer have these problems. 
> 
> I'd appreciate any suggestions.
> 
> The applicable code is listed here:
> 
> unsigned long int getTickCounter (void);
> void T0_ISR (void) __arm __fiq;
> unsigned long int tickCount = 0;
> 
> 
> 
> 	T0MR0 = PCLK/200; // Every 50ms
> 	T0IR = 0xF;	// Clear Interrupts on MR0	
> 	T0MCR = 0x03;  // Reset and Interrupt on MR0
> 	VICIntEnable = 1 << 4;
> 	VICVectAddr3 = (unsigned long)T0_ISR;
> 	VICVectCntl3 = 0x20 | 4;
> 	T0TCR = 0x2;	// Reset the timer
> 	T0TCR = 0x1;	// Start the timer
> 
> 
> void T0_ISR(void) __arm __fiq {
> 	tickCount++;
> 
> 	// Clear Interrupts
> 	VICVectAddr = 0;
> 	T0IR = 0x1;	
> }
> 
> 
> This is a very useful function!
> void DAbt_Handler(void) __arm __irq {
> 	Uint32 i;	
> 	// Grab the return address (location where mem access failed)
> 	__asm	{STAV R14, R0, i};
> 	printf("*****Data abort occured 0x%x *****", i);
> 	// Now just spin
> 	while(1);
> }

Re: Strange timer problem

2005-03-30 by Leighton Rowe

Peter,

What's your current configuration of the stack pointers (in User 
mode,IRQ,FIQ, etc.)? Chances are that the Data aborts you've been 
getting are due to stack overflows, which usually leads to the 
assembly registers having unexpected values during code execution. 
Stack Overflows are the toughest errors to catch, even when 
debugging the machine thru JTAG. 
 
Leighton

--- In lpc2000@yahoogroups.com, "peterburdine" <lordofdawn@h...> 
wrote:
> 
> I figured it out.  It didn't work as and irq, so I switched it to 
fiq
> and added VICIntSelect = 1<<4; and it seems to work just fine now. 
> Although I wonder why it didn't work as an irq.  And yes I know 
that
> when the msg was first posted I had __fiq on the ISR, that was my
> halfway between code, I had __irq on them originally.
> 
> --Peter
> 
> --- In lpc2000@yahoogroups.com, "peterburdine" <lordofdawn@h...> 
wrote:
> > 
> > I'm using the Keil's compiler and I'm trying to setup a system 
clock
> > that increments every 5ms.  I am doing this by having a unsigned 
long
> > int that gets incremented on the timer interrupt.  The timer also
> > resets when the interrupt occurs.  The problem is this seems to
> > somehow corrupt a few registers every once in a while and will
> > generally end up in a data abort.  I believe the timer must be 
the
Show quoted textHide quoted text
> > cause because if I remove it, I no longer have these problems. 
> > 
> > I'd appreciate any suggestions.
> > 
> > The applicable code is listed here:
> > 
> > unsigned long int getTickCounter (void);
> > void T0_ISR (void) __arm __fiq;
> > unsigned long int tickCount = 0;
> > 
> > 
> > 
> > 	T0MR0 = PCLK/200; // Every 50ms
> > 	T0IR = 0xF;	// Clear Interrupts on MR0	
> > 	T0MCR = 0x03;  // Reset and Interrupt on MR0
> > 	VICIntEnable = 1 << 4;
> > 	VICVectAddr3 = (unsigned long)T0_ISR;
> > 	VICVectCntl3 = 0x20 | 4;
> > 	T0TCR = 0x2;	// Reset the timer
> > 	T0TCR = 0x1;	// Start the timer
> > 
> > 
> > void T0_ISR(void) __arm __fiq {
> > 	tickCount++;
> > 
> > 	// Clear Interrupts
> > 	VICVectAddr = 0;
> > 	T0IR = 0x1;	
> > }
> > 
> > 
> > This is a very useful function!
> > void DAbt_Handler(void) __arm __irq {
> > 	Uint32 i;	
> > 	// Grab the return address (location where mem access failed)
> > 	__asm	{STAV R14, R0, i};
> > 	printf("*****Data abort occured 0x%x *****", i);
> > 	// Now just spin
> > 	while(1);
> > }

RE: [lpc2000] Strange timer problem

2005-03-30 by Mark Crow

When you execute:

      VICVectAddr = 0;
you allow the VIC to post another IRQ interrupt.  This should be the last
operation performed before exiting the IRQ function.

Could you try:

      T0IR = 0x1;
      VICVectAddr = 0;
Show quoted textHide quoted text
  -----Original Message-----
  From: peterburdine [mailto:lordofdawn@...]
  Sent: Wednesday, March 30, 2005 11:54 AM
  To: lpc2000@yahoogroups.com
  Subject: [lpc2000] Strange timer problem



  I'm using the Keil's compiler and I'm trying to setup a system clock
  that increments every 5ms.  I am doing this by having a unsigned long
  int that gets incremented on the timer interrupt.  The timer also
  resets when the interrupt occurs.  The problem is this seems to
  somehow corrupt a few registers every once in a while and will
  generally end up in a data abort.  I believe the timer must be the
  cause because if I remove it, I no longer have these problems.

  I'd appreciate any suggestions.

  The applicable code is listed here:

  unsigned long int getTickCounter (void);
  void T0_ISR (void) __arm __fiq;
  unsigned long int tickCount = 0;



        T0MR0 = PCLK/200; // Every 50ms
        T0IR = 0xF;      // Clear Interrupts on MR0
        T0MCR = 0x03;  // Reset and Interrupt on MR0
        VICIntEnable = 1 << 4;
        VICVectAddr3 = (unsigned long)T0_ISR;
        VICVectCntl3 = 0x20 | 4;
        T0TCR = 0x2;      // Reset the timer
        T0TCR = 0x1;      // Start the timer


  void T0_ISR(void) __arm __fiq {
        tickCount++;

        // Clear Interrupts
        VICVectAddr = 0;
        T0IR = 0x1;
  }


  This is a very useful function!
  void DAbt_Handler(void) __arm __irq {
        Uint32 i;
        // Grab the return address (location where mem access failed)
        __asm      {STAV R14, R0, i};
        printf("*****Data abort occured 0x%x *****", i);
        // Now just spin
        while(1);
  }





        Yahoo! Groups Sponsor
              ADVERTISEMENT





----------------------------------------------------------------------------
--
  Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/lpc2000/

    b.. To unsubscribe from this group, send an email to:
    lpc2000-unsubscribe@yahoogroups.com

    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



[Non-text portions of this message have been removed]

RE: [lpc2000] Re: Strange timer problem

2005-03-30 by Mark Crow

Refering to my earlier response, the

>       VICVectAddr = 0;
should be the last thing the high-level IRQ handler should do (the routine
whose address is in the exception vector IRQ slot).
Show quoted textHide quoted text
  -----Original Message-----
  From: peterburdine [mailto:lordofdawn@...]
  Sent: Wednesday, March 30, 2005 12:14 PM
  To: lpc2000@yahoogroups.com
  Subject: [lpc2000] Re: Strange timer problem



  I figured it out.  It didn't work as and irq, so I switched it to fiq
  and added VICIntSelect = 1<<4; and it seems to work just fine now.
  Although I wonder why it didn't work as an irq.  And yes I know that
  when the msg was first posted I had __fiq on the ISR, that was my
  halfway between code, I had __irq on them originally.

  --Peter

  --- In lpc2000@yahoogroups.com, "peterburdine" <lordofdawn@h...> wrote:
  >
  > I'm using the Keil's compiler and I'm trying to setup a system clock
  > that increments every 5ms.  I am doing this by having a unsigned long
  > int that gets incremented on the timer interrupt.  The timer also
  > resets when the interrupt occurs.  The problem is this seems to
  > somehow corrupt a few registers every once in a while and will
  > generally end up in a data abort.  I believe the timer must be the
  > cause because if I remove it, I no longer have these problems.
  >
  > I'd appreciate any suggestions.
  >
  > The applicable code is listed here:
  >
  > unsigned long int getTickCounter (void);
  > void T0_ISR (void) __arm __fiq;
  > unsigned long int tickCount = 0;
  >
  >
  >
  >       T0MR0 = PCLK/200; // Every 50ms
  >       T0IR = 0xF;      // Clear Interrupts on MR0
  >       T0MCR = 0x03;  // Reset and Interrupt on MR0
  >       VICIntEnable = 1 << 4;
  >       VICVectAddr3 = (unsigned long)T0_ISR;
  >       VICVectCntl3 = 0x20 | 4;
  >       T0TCR = 0x2;      // Reset the timer
  >       T0TCR = 0x1;      // Start the timer
  >
  >
  > void T0_ISR(void) __arm __fiq {
  >       tickCount++;
  >
  >       // Clear Interrupts
  >       VICVectAddr = 0;
  >       T0IR = 0x1;
  > }
  >
  >
  > This is a very useful function!
  > void DAbt_Handler(void) __arm __irq {
  >       Uint32 i;
  >       // Grab the return address (location where mem access failed)
  >       __asm      {STAV R14, R0, i};
  >       printf("*****Data abort occured 0x%x *****", i);
  >       // Now just spin
  >       while(1);
  > }




        Yahoo! Groups Sponsor
              ADVERTISEMENT





----------------------------------------------------------------------------
--
  Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/lpc2000/

    b.. To unsubscribe from this group, send an email to:
    lpc2000-unsubscribe@yahoogroups.com

    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



[Non-text portions of this message have been removed]

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.