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.

How to Handle Timer2 in 8052 family

Status
Not open for further replies.

nikhileshsawarkar

Newbie level 5
Joined
Jul 17, 2006
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,352
8052 timer 2

Hi again experts,
Some problem in handling my Timer2.
I'm using 8052 series AT89s8253 controller. I'm using Timer2 as 16 bit auto reload mode.My compiler is Keil uV2. I wanted to get interrupt every 1 ms so values I've set in RCAP2H = 0xFC and RCAP2L = 0x65.
the code is

//in main
timer2_init()
{
RCAP2H = 0xFC ;
RCAP2L = 0x65;
T2CON |= 0x00;
T2H = 0xFC ;
T2L = 0x65;
TR2 = 1;
}
//isr get called every 1ms
int counter = 0;//global int

timer2_isr () interrupt 5 using 1
{
counter++;
if(counter == 60000)//will go inside every 1 min.
{
counter = 0; //X ZONE
}

}


But Im getting something wrong...
1. Regardless of any value I put in RCAP2H and RCAP2L , Its going in 'X zone' every 12 seconds(approx) but not in every min (This I've observed in Debugger and CRO both)
2. It is exicuting isr every 0.1 ms(approx) insted of 1ms.

My Q is is there any other presetting required for it to be working correctly?

Thanks and regards,:D
Nikhilesh
 

+8052 +timer2

Hi nikhileshsawarkar

What clock rate are you using?

Are you clearing the interupt flag? If not, you will get a repeated interupt as soon as you exit the ISR.

regards ... Polymath
 
at89s8253 timer2

Got it dear !!
I was not clearing interrupt flag(TF2) in isr.
Now it has started working,
ThanX:D
Nikhilesh
 

timer2 8052 keil

Can somone please tell me what's the purpose of "using 1" in line "timer2_isr () interrupt 5 using 1 "
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top