Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interrupt IRQ timer0 of LPC2148 help

Status
Not open for further replies.

hbaocr

Full Member level 4
Joined
May 13, 2007
Messages
232
Helped
25
Reputation
48
Reaction score
4
Trophy points
1,298
Location
Hochiminh City university of technology (VietNam)
Activity points
2,765
hello;
I have make example code for IRQ timer match0 and I have som problems
please help me!
why my program loop at ISRIRQ_Match0_timer0 forever( return and then immediately jump to ISR again and again without working function in main program to Increase a value).So variabe f intially change (f=a) at first match occur and until the other match occurr following it ,variale a don't change (it don't increase)


#include "LPC214x.H"
#include "stdio.h"
//CCLK=12xM=12x5=60MHZ
//PCLK=CCLK (VPBDIV=0x00)
void IRQ_Match0_timer0(void)__irq;
unsigned int a;
unsigned int f;
int main()
{

//int timer0
T0TCR=0x3;//TC and PR count enable
T0PR=59;//tan so dem cua TC = PCLK/(PR+1)=1MHz-> 1us
T0MCR=0x1;//interrupt match0 enable and TC reset when match
T0MR0=3;//10us for TC reaches to T0MR0 and occur match0
//interrupt
VICVectCntl0=0x24;//choose Source Int Timer0=4, and enable IRQ slot
VICVectAddr0=(unsigned) IRQ_Match0_timer0;
VICIntEnable=1<<4;//enable Timer0 interrupt source
T0TCR=0x1;
while(1)
{
a++;
}
}
void IRQ_Match0_timer0(void)__irq
{

f=a ;
T0IR=0;
VICVectAddr = 0x00000000; // Reset Global Interrupt and return
}
 

Because timer0 is being held in reset, the interrupt fires as soon as you enable it and the timer never starts. start timer0 before you enable the timer0 interrupt.

Also TC reset is not enabled,

T0MCR=0x1;//interrupt match0 enable and TC reset when match

Change to:

T0MCR=0x3;//interrupt match0 enable and TC reset when match
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top