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 use timer2 of 8051 ?

Status
Not open for further replies.

ucsam

Advanced Member level 4
Joined
Oct 12, 2010
Messages
119
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
kathmandu,nepal
Activity points
2,058
hey! guys

i wanted to use the timer 2 of 8051 to use it as the multiplexing delay for seven segment led display. So guys if anyone of u know how can i use timer 2 of 8051 please give the pseudocode or C code or assembly code will work too.

thanks
 

Re: using timer2 of 8051

using timer 2 without interrupt :

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
VH      Equ 04Ch
VL      Equ 000h
;XTAL = 11059200
;10000h - 4C00h = B400h = 46080 cycles => 46080/(11059200/12) = 50 ms
Begin:
    Clr Tr2
    Mov Th2,#VH
    Mov Tl2,#VL
    Mov Rcap2h,#VH
    Mov Rcap2l,#VL
    Clr Tf2
    Setb Tr2
 
Main:
    Jnb Tf2,$
    Clr Tf2
    Acall Refresh_Display
    Sjmp Main



using timer 2 with interrupt :

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
VH      Equ 04Ch
VL      Equ 000h
;XTAL = 11059200
;10000h - 4C00h = B400h = 46080 cycles => 46080/(11059200/12) = 50 ms
Begin:
    Ajmp Init
    Org 02Bh
    Clr Tf2
    Acall Refresh_Display
    Reti
 
Init:
    Clr Tr2
    Mov Th2,#VH
    Mov Tl2,#VL
    Mov Rcap2h,#VH
    Mov Rcap2l,#VL
    Clr Tf2
    Mov Ie,#A0h
    Setb Tr2
 
Main:
    Sjmp $

 
Last edited:

Re: using timer2 of 8051

can any one add a mikrobasic code for timer two that-lets say- drive LED when over flow occur (for PIC 16f877a)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top