Yahoo Groups archive

Lpc2000

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

Thread

LPC2138 Timer0 Interrupt

LPC2138 Timer0 Interrupt

2005-12-08 by dodge1955

Can anyone tell me why my interrupt is not firing? The T0IR flag is
set upon rollover of the TIMER0 32 bit timer, but my code is not
vectored to the interrupt code. My variable 'system_timer' never gets
decremented.

unsigned long system_timer, j;

void decrement_timers() __irq
{
// occurs 896 times per second

system_timer--;

T0IR |= 1;
}

int main()
{
VPBDIV = 1;

// set up delay timer (TIMER 0)

VICIntSelect = 0; // all interrupts classified as IRQs
VICVectCntl0 = 0x00000024;
VICVectAddr0 = (unsigned int) decrement_timers;
VICIntEnable = 0x00000010;

// Disable Timer0 and Reset Interrupt Flag

T0TCR = 0;
T0IR |= 1;

T0MR0 = 0;
T0MCR = 1;

T0CTCR = 0;
T0PR = 0;
T0TCR = 1;

// just an infinite loop to check Timer0

system_timer = 4000;

j = 0;
for(;;)
{
j = j + 2;
}

Re: LPC2138 Timer0 Interrupt

2005-12-08 by Randy Ott

Maybe interrupts are not enabled?

--- In lpc2000@yahoogroups.com, "dodge1955" <sutton@h...> wrote:
>
> Can anyone tell me why my interrupt is not firing? The T0IR flag is
> set upon rollover of the TIMER0 32 bit timer, but my code is not
> vectored to the interrupt code. My variable 'system_timer' never 
gets
Show quoted textHide quoted text
> decremented.
> 
> unsigned long system_timer, j;
> 
> void decrement_timers() __irq
> {
> // occurs 896 times per second
> 
> system_timer--;
> 
> T0IR |= 1;
> }
> 
> int main()
> {
> VPBDIV = 1;
> 
> // set up delay timer (TIMER 0)
> 
> VICIntSelect = 0; // all interrupts classified as IRQs
> VICVectCntl0 = 0x00000024;
> VICVectAddr0 = (unsigned int) decrement_timers;
> VICIntEnable = 0x00000010;
> 
> // Disable Timer0 and Reset Interrupt Flag
> 
> T0TCR = 0;
> T0IR |= 1;
> 
> T0MR0 = 0;
> T0MCR = 1;
> 
> T0CTCR = 0;
> T0PR = 0;
> T0TCR = 1;
> 
> // just an infinite loop to check Timer0
> 
> system_timer = 4000;
> 
> j = 0;
> for(;;)
> {
> j = j + 2;
> }
>

Re: LPC2138 Timer0 Interrupt

2005-12-08 by mark_dell555

Make sure your global IRQ flag is clear, (I_BIT in CPSR needs to be
0).  Also you need to clear the VICVectAddr (VICVectAddr = 0x00000000)
at the end of your interrupt.  

Other then that it should work, however if wont occur 896 times per
second, more like once every 71s with a 60Mhz PCLK.

Mark

--- In lpc2000@yahoogroups.com, "dodge1955" <sutton@h...> wrote:
Show quoted textHide quoted text
>
> Can anyone tell me why my interrupt is not firing? The T0IR flag is
> set upon rollover of the TIMER0 32 bit timer, but my code is not
> vectored to the interrupt code. My variable 'system_timer' never gets
> decremented.
> 
> unsigned long system_timer, j;
> 
> void decrement_timers() __irq
> {
> // occurs 896 times per second
> 
> system_timer--;
> 
> T0IR |= 1;
> }
> 
> int main()
> {
> VPBDIV = 1;
> 
> // set up delay timer (TIMER 0)
> 
> VICIntSelect = 0; // all interrupts classified as IRQs
> VICVectCntl0 = 0x00000024;
> VICVectAddr0 = (unsigned int) decrement_timers;
> VICIntEnable = 0x00000010;
> 
> // Disable Timer0 and Reset Interrupt Flag
> 
> T0TCR = 0;
> T0IR |= 1;
> 
> T0MR0 = 0;
> T0MCR = 1;
> 
> T0CTCR = 0;
> T0PR = 0;
> T0TCR = 1;
> 
> // just an infinite loop to check Timer0
> 
> system_timer = 4000;
> 
> j = 0;
> for(;;)
> {
> j = j + 2;
> }
>

SV: [lpc2000] LPC2138 Timer0 Interrupt

2005-12-08 by Jørgen Daugaard

Maybe you forgot to enable global interrupt just before entering the loop?

 

 // just an infinite loop to check Timer0

system_timer = 4000;
__ARMLIB_enableIRQ();


j = 0;
for(;;)
{
j = j + 2;
}
 

/jd 

  _____  

Fra: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] På vegne af
dodge1955
Sendt: 8. december 2005 17:51
Til: lpc2000@yahoogroups.com
Emne: [lpc2000] LPC2138 Timer0 Interrupt

 

Can anyone tell me why my interrupt is not firing? The T0IR flag is
set upon rollover of the TIMER0 32 bit timer, but my code is not
vectored to the interrupt code. My variable 'system_timer' never gets
decremented.

unsigned long system_timer, j;

void decrement_timers() __irq
{
// occurs 896 times per second

system_timer--;

T0IR |= 1;
}

int main()
{
VPBDIV = 1;

// set up delay timer (TIMER 0)

VICIntSelect = 0; // all interrupts classified as IRQs
VICVectCntl0 = 0x00000024;
VICVectAddr0 = (unsigned int) decrement_timers;
VICIntEnable = 0x00000010;

// Disable Timer0 and Reset Interrupt Flag

T0TCR = 0;
T0IR |= 1;

T0MR0 = 0;
T0MCR = 1;

T0CTCR = 0;
T0PR = 0;
T0TCR = 1;

// just an infinite loop to check Timer0

system_timer = 4000;

j = 0;
for(;;)
{
j = j + 2;
}






SPONSORED LINKS 


Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Mic
rocontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=t
sVC-J9hJ5qyXg0WPR0l6g>  

Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=M
icrocontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig
=DvJVNqC_pqRTm8Xq01nxwg>  

Pic
<http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&
w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&
.sig=TpkoX4KofDJ7c6LyBvUqVQ>  microcontrollers 


8051
<http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocessor&w
2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.
sig=1Ipf1Fjfbd_HVIlekkDP-A>  microprocessor 

 

 

 

  _____  

YAHOO! GROUPS LINKS 

 

*	 Visit your group "lpc2000 <http://groups.yahoo.com/group/lpc2000> "
on the web.
  
*	 To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
  
*	 Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/>  Terms of Service. 

 

  _____  



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

Re: LPC2138 Timer0 Interrupt

2005-12-08 by Ken Wada

First of all; you are not acknowledging your VIC interrupt. This will 
cause your system to 'look' like it is not interrupting.

void decrement_timers() __irq
{
    // occurs 896 times per second
    system_timer--;
    T0IR = 1;
    VICVectAddr = 0;     /* <--- Acknowledge VIC Interrupt !!! */
}

plus: Here is a snippet from an initialization routine that I use, and 
it works perfectly:

extern unsigned long acquireFOSC(void);  // VPB clock in Hertz

void Timer0_init (const unsigned vicSlot)
{
    /*** some sundry global variable initializations here ***/
      ...
      ...
      ...

    /*** now initialize the timer and install the service ***/
    T0PR  = (acquireFOSC () / 2000) - 1;/* Prescaler ~ .0005 sec    */
    T0MR0 = 1;                          /* Set MR0 count = .001 sec */
    T0MCR = 0x03;                       /* Set to reset & interrupt */
    VIC_install (vicSlot,VICCH_TMR0,TMR0_isr); //install the service
    T0TCR = 1;                          /* Timer0 Enable            */
}

--- In lpc2000@yahoogroups.com, "dodge1955" <sutton@h...> wrote:
>
> Can anyone tell me why my interrupt is not firing? The T0IR flag is
> set upon rollover of the TIMER0 32 bit timer, but my code is not
> vectored to the interrupt code. My variable 'system_timer' never 
gets
Show quoted textHide quoted text
> decremented.
> 
> unsigned long system_timer, j;
> 
> void decrement_timers() __irq
> {
> // occurs 896 times per second
> 
> system_timer--;
> 
> T0IR |= 1;
> }
> 
> int main()
> {
> VPBDIV = 1;
> 
> // set up delay timer (TIMER 0)
> 
> VICIntSelect = 0; // all interrupts classified as IRQs
> VICVectCntl0 = 0x00000024;
> VICVectAddr0 = (unsigned int) decrement_timers;
> VICIntEnable = 0x00000010;
> 
> // Disable Timer0 and Reset Interrupt Flag
> 
> T0TCR = 0;
> T0IR |= 1;
> 
> T0MR0 = 0;
> T0MCR = 1;
> 
> T0CTCR = 0;
> T0PR = 0;
> T0TCR = 1;
> 
> // just an infinite loop to check Timer0
> 
> system_timer = 4000;
> 
> j = 0;
> for(;;)
> {
> j = j + 2;
> }
>

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.