wajid ali khan
Newbie level 6
Is there anyone who could help me design counter counting over 255 in mod2 of 8051 counter....
.thanks in advance
:sad:
.thanks in advance
:sad:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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:
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
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
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
Code ASM - [expand] 1 sixteenBitNumber = (upperByte<<8) | lowerByte;