Yahoo Groups archive

Lpc2000

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

Thread

Timer issues

Timer issues

2005-07-26 by soren_t_hansen

I'm having some problems with the timer on a lpc2132 in the following
way: I'm developing a program which I'm running from RAM while
debugging. I've set up MEMMAP=2 to remap the interrupt vectors and it
does work .... sometimes. Here goes ..

I use Eclipse with the Zylin embedded plugin. When I want to debug I
download the program and starts execution. But the first time I end up
in the DApt_Handler no matter what. Then I download the program once
more (without powercycling the board) and this time it all runs
without problems (I'm watching a global counter). If I then try to
download once more, it sometimes work and sometimes don't.
I have the ADC running at the same time and it suffers the same
problems, but if I run without the timer and just the ADC it works
like a charm. If I run the Timer without the ADC I still get the problem.

I have the following code to setup my timer:
  // 15000 counts * 1/15 MHz = 1000 uS (1 kHz)	
  T0MR0 = 14999;	   					
  
  // Interrupt and Reset on MR0   
  T0MCR = 3;                            
  
  // Timer0 Enable                
  T0TCR = 1;                 
             
  // set interrupt vector    
  VICVectAddr1 = (unsigned long)tc0;    
  
  // use it for Timer 0 Interrupt 
  VICVectCntl1 = 0x20 | 4;      
          
  // Enable Timer0 Interrupt	
  VICIntEnable |= 0x00000010;

The interrupt handler looks like this:

	void tc0 (void) __attribute__ ((interrupt ("IRQ")));    
	
	void tc0 (void)
	{
		count++;
		
		// Clear interrupt flag
	 	T0IR = 1; 
		// Acknowledge interrupt      
		VICVectAddr = 0;                              
  	}

Has anyone encountered this problem, or is able to see whats causing
the problem? I'm drawing blanks ...

Best Regards
Søren

Re: [lpc2000] Timer issues

2005-07-26 by 42Bastian Schick

soren_t_hansen <soren_t_hansen@...> schrieb am Tue, 26 Jul 2005 
08:16:23 -0000:

> I'm having some problems with the timer on a lpc2132 in the following
> way: I'm developing a program which I'm running from RAM while
> debugging. I've set up MEMMAP=2 to remap the interrupt vectors and it
> does work .... sometimes. Here goes ..
>
> I use Eclipse with the Zylin embedded plugin. When I want to debug I
> download the program and starts execution. But the first time I end up
> in the DApt_Handler no matter what. Then I download the program once
> more (without powercycling the board) and this time it all runs
> without problems (I'm watching a global counter). If I then try to
> download once more, it sometimes work and sometimes don't.
> I have the ADC running at the same time and it suffers the same
> problems, but if I run without the timer and just the ADC it works
> like a charm. If I run the Timer without the ADC I still get the problem.

You should reset the VIC (disable all interrupts) before downloading
(gdb init script).
Be also sure you have MEMMAP set correctly before downloading.
I link my vectors at 0 so I set MEMMAP to 2 before. If you link
your vectors to 0x40000000 be sure to set MEMMAP to 0, and your code
sets it to 2.


-- 
42Bastian Schick

Re: Timer issues

2005-07-26 by soren_t_hansen

--- In lpc2000@yahoogroups.com, 42Bastian Schick <bastian42@m...> wrote:
> soren_t_hansen <soren_t_hansen@y...> schrieb am Tue, 26 Jul 2005 
> 08:16:23 -0000:
> 
> > I'm having some problems with the timer on a lpc2132 in the following
> > way: I'm developing a program which I'm running from RAM while
> > debugging. I've set up MEMMAP=2 to remap the interrupt vectors and it
> > does work .... sometimes. Here goes ..
> >
> > I use Eclipse with the Zylin embedded plugin. When I want to debug I
> > download the program and starts execution. But the first time I end up
> > in the DApt_Handler no matter what. Then I download the program once
> > more (without powercycling the board) and this time it all runs
> > without problems (I'm watching a global counter). If I then try to
> > download once more, it sometimes work and sometimes don't.
> > I have the ADC running at the same time and it suffers the same
> > problems, but if I run without the timer and just the ADC it works
> > like a charm. If I run the Timer without the ADC I still get the
problem.
> 
> You should reset the VIC (disable all interrupts) before downloading
> (gdb init script).
> Be also sure you have MEMMAP set correctly before downloading.
> I link my vectors at 0 so I set MEMMAP to 2 before. If you link
> your vectors to 0x40000000 be sure to set MEMMAP to 0, and your code
> sets it to 2.
> 

I'm rather new at this embedded programming, and especially with the
ARM7, so if you could clarify how to do the things you just mentioned,
I would be very thankfull.
As it is now I link my vectors to 0x40000000 :

MEMORY
{
  CODE (rx) : ORIGIN = 0x40000000, LENGTH = 0x00003000
  DATA (rw) : ORIGIN = 0x40003000, LENGTH = 0x00001000
}

/* Section Definitions */
SECTIONS
{
  /* first section is .text which is used for code */
  .text :
 {
    *crt0.arm.o (.text)            /* Startup code */
    *(.text)                   /* remaining code */
    *(.glue_7t) *(.glue_7)
  } >CODE =0
 ....etc etc

I set my MEMMAP to 2 in the startup code with: 
MEMMAP_USER_RAM_MODE    = (1<<1)

void _c_startup(void)
{
	initSegments();
	initPLL();
	initMAM();
	MEMMAP = MEMMAP_USER_RAM_MODE;
	runCppCtors();
}

/Søren

Re: [lpc2000] Re: Timer issues

2005-07-26 by 42Bastian Schick

soren

>> You should reset the VIC (disable all interrupts) before downloading
>> (gdb init script).

Others may be of more help, as I normaly use commercial debuggers.
But IIRC you can execute scripts on gdb startup.
This script should

a) (in your case) write 0 to memmap
b) write 0xffffffff to VicIntEnClear


-- 
42Bastian Schick

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.