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 make count up ?

Status
Not open for further replies.
thank you very much for help me now i really happy because i can do this .....
i have tuning this and it reallly workkk when click pattern it increment and when click stop button it reset to 00
thank you very much


HTML:
			  Org    00H

        data_one    equ    P3
        data_ten    equ    P2
	IPIN		EQU	P1.0
	DPIN		EQU	P1.1
        Mynumber    Equ    30H 

main_prog:  
	CALL INIT
AGAIN:

AG2:	JB IPIN,AG1
	CALL DELAY1	;debounce
	JB IPIN,AG1
	JNB IPIN,$	;wait till switch release
	INC MYNUMBER
	mov a,mynumber
	cjne a,#100,pq1
	mov mynumber,#0
pq1:
	call bcd	;diaplay data


AG1:	JB DPIN,AG2
	CALL DELAY1
	JB DPIN,AG2
	JNB DPIN,$   
	clr mynumber     
	mov a,#0C0H
	cjne a,#0C0H,pq2
	mov mynumber,#00
pq2:
	call bcd
	JMP AGAIN


INIT:
	MOV    data_ten,#0C0H
        MOV    data_one,#0c0H
        mov    Mynumber,#0
        mov    p1,#255        ;set port 1 as input BY . IT SHOULD BE 1
RET

DELAY1:	MOV R4,#255
	DJNZ R4,$
RET
   
BCD:    Mov     A,Mynumber
        Mov     B,#10
        Div    AB    

	mov dptr,#seg_conv 
	MOVC A,@A+DPTR    ; MOVE DATA @A+DPTR IN A     
        mov    data_ten, A  

        mov    A,B
        mov dptr,#seg_conv 
	MOVC A,@A+DPTR    ; MOVE DATA @A+DPTR IN A     
        mov    data_one, A  
Ret

delay:  MOV    R5,#0ffh
        MOV    R6,#0ffH
        MOV    R7,#2
delay_loop:    DJNZ    R5,delay_loop
        DJNZ    R6,delay_loop
        DJNZ    R7,delay_loop
        RET
    
Seg_conv:  
	DB    0C0H    ; 0
        DB    0F9H    ; 1
        DB    0A4H    ; 2
        DB    0B0H    ; 3
        DB    099H    ; 4
        DB    092H    ; 5
        DB    082H    ; 6
        DB    0F8H    ; 7
        DB    080H    ; 8
        DB    090H    ; 9

        END
 

Attachments

  • newone.png
    newone.png
    50.5 KB · Views: 70

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top