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.

[moved] 8051 counter to count over 255

Status
Not open for further replies.

wajid ali khan

Newbie level 6
Joined
Jan 1, 2015
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
66
Is there anyone who could help me design counter counting over 255 in mod2 of 8051 counter....
.thanks in advance
:sad:
 


8051 counter to count over 255

plz help me... i design a counter in 8051 that can count upto 255 in mod1 and also display upto 255 on 7segment displays ..after 255 it again starts counting from 001 so how should i combine TH0 with TL0
to get over 255.....
thanks in advance
:sad:
 

Re: 8051 counter to count over 255

plz help me... i design a counter in 8051 that can count upto 255 in mod1 and also display upto 255 on 7segment displays ..after 255 it again starts counting from 001 so how should i combine TH0 with TL0
to get over 255.....
thanks in advance
:sad:

post your code here to help you better
 

Re: 8051 counter to count over 255


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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ORG 00H
MOV TMOD,#05H
MOV TL0,#00H
MOV TH0,#00H
SETB P3.4
MOV P1,#00H
 
SETB TR0
 
NEXT:MOV A,TL0
 
CJNE A,#100,GO
GO:JC TEN
 
 
MOV B,#100 ;;covert hex to decimel
DIV AB
MOV P1,A
MOV A,B
MOV B,#10
DIV AB
SWAP A
ORL A,B
MOV P2,A
SJMP HERE
 
 
TEN:;;convert hex to decimel
MOV B,#10
DIV AB
SWAP A
 ORL A,B
 MOV P2,A
 SJMP HERE
 
 
HERE:JNB TF0,NEXT
CLR TR0
CLR TF0
END

 
Last edited by a moderator:

is there any one to help me how to count over 255 in 8051 counter..... the following code can count upto 255...
Code:
ORG 00H
MOV TMOD,#05H
MOV TL0,#00H
MOV TH0,#00H
SETB P3.4
MOV P1,#00H
 
SETB TR0
 
NEXT:MOV A,TL0
 
CJNE A,#100,GO
GO:JC TEN
 
 
MOV B,#100 ;;covert hex to decimel
DIV AB
MOV P1,A
MOV A,B
MOV B,#10
DIV AB
SWAP A
ORL A,B
MOV P2,A
SJMP HERE
 
 
TEN:;;convert hex to decimel
MOV B,#10
DIV AB
SWAP A
 ORL A,B
 MOV P2,A
 SJMP HERE
 
 
HERE:JNB TF0,NEXT
CLR TR0
CLR TF0
END
 

you can do by declaring one variable which count increment every time your timer overflows. see the below attached example
 

Attachments

  • FreqCounter.zip
    109.6 KB · Views: 84

    V

    Points: 2
    Helpful Answer Positive Rating
you can do by declaring one variable which count increment every time your timer overflows. see the below attached example

i am giving output to 7 segment display and the one u(ud23) mentioned is about lcd.
i m giving output from the accumulator to ports and accumulator can keep maxmum upto 255....
 


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
24
; Note: a logic 0 lights a display segment.
 
start:
        SETB P3.3               ; |
        SETB P3.4               ; | enable display 3
        MOV P1, #11111001B      ; put pattern for 1 on display
        CALL delay
        CLR P3.3                ; enable display 2
        MOV P1, #10100100B      ; put pattern for 2 on display
        CALL delay
        CLR P3.4                ; |
        SETB P3.3               ; | enable display 1
        MOV P1, #10110000B      ; put pattern for 3 on display
        CALL delay
        CLR P3.3                ; enable display 0
        MOV P1, #10011001B      ; put pattern for 4 on display
        CALL delay
        JMP start               ; jump back to start
 
; a crude delay
delay:
        MOV R0, #200
        DJNZ R0, $
        RET



this is basic code for display 4 7 segment in multiplexing

for converting two byte in single 16 bit

Code ASM - [expand]
1
sixteenBitNumber = (upperByte<<8) | lowerByte;



for storing 16bit you can use dptr reg
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top