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.

Help me calculate RCAP2H and RCAP2L registers for P89C51RD2 Timer-2

Status
Not open for further replies.

CMOS

Advanced Member level 3
Joined
Jan 6, 2004
Messages
862
Helped
94
Reputation
186
Reaction score
50
Trophy points
1,308
Location
USA
Activity points
5,673
Hi,
In one of my 89C51RD2 programs, I am using Timer-2 to generate 100µS delay. I used the following formula to calculate values for RCAP2H and RCAP2L register. 89C51RD2 is used in 12-clock mode and Timer-2 is in mode-0 i.e 16-bit auto-reload mode.

RCAP2H,RCAP2L = 65536 - ((Fosc. * delay) / 12)

I want to confirm whether this formula is correct for Timer-2 or not since no formula for "timer" mode is given in the datasheet.
 

Re: P89C51RD2 Timer-2

Yes, this is the right formula...
 

Re: P89C51RD2 Timer-2

I still doub't whether this formula is correct because no where in Timer2 formula in the datasheet the "12" in denominator is present. All formulae has 2, 4, 16 or 32 in the denominator.

Is there any way I could check my calculations or rather the delay for correctness. I am basically working on a application where 100uS precise timing is required and I am not getting satisfactory results.
 

Re: P89C51RD2 Timer-2

From the block diagram Timer2 in Auto-Reload Mode and with C/T2=0 the Fosc is devided by 12..hence in the formula you use division by this number.
As BaudRate Generator the the Fosc is first devided by 2 (not twelve) and then by 16...that gives you division by 32..

If you are worried about time accuracy then another option is to set bit C/T2 and use pin T2 (P1.0) as input for external accurate frequency source..

But 100µs (or close to) should be achievable with internal clock..
 

    CMOS

    Points: 2
    Helpful Answer Positive Rating
Re: P89C51RD2 Timer-2

Remember to set the Timer2 interrupt to the highest priority - otherwise you will
get extra delay caused by other interrupt routines.

/Rambo
 

    CMOS

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top