??? 10/25/06 01:29 Read: times |
#126965 - AT89C51 countdown timer |
I am currently working on a project that will count down in decimal from 99-0 using an AT89C51 microcontroller, two 4511 BCDs, and two 7 segment displays. I was able to create a counter that will count from 0-99, but I don't know about how to countdown because a DA A cannot be used after a SUB A. Here is my code for counting up. I need help on how to countdown.
.EQU COUNT,30H .EQU PASS,20H ; MAIN PROGRAM MOV TMOD,#01H ;SET TIMER0 MODE TO 1 MOV COUNT,#00H ;SET COUNT TO 00 MOV A,COUNT ;MOVE COUNT TO ACCUMULATOR MOV P1,A ;OUTPUT 00 DC0: MOV PASS,#05H ;SETS TIME DELAY TO 1 SEC.DELAY MOV TL0,#0ECH ;SET LOW BYTE TO 68 DECIMAL MOV TH0,#16H ;SET HIGH BYTE TO 58 DECIMAL DC1: SETB TR0 ;START TIMER DD1: JNB TF0,DD1 ;WAIT FOR OVERFLOW CLR TF0 ;CLEAR FLAG CLR TR0 ;STOP TIMER DJNZ PASS,DC1 ;LOOP 5 TIMES BEG: MOV A,COUNT ;MOVE COUNT TO ACCUMULATOR ADD A,#01H ;ADD 1 TO ACCUMULATOR DA A ;DECIMAL ADJUST A MOV COUNT,A ;MOVE ACCUM NUMBER BACK TO COUNT SWTCH: SETB P3.0 ;CHECK P3.0 SWITCH JNB P3.0,SWTCH MOV P1,COUNT ;OUTPUT NUMBER TO LEDS SJMP DC0 ;JUMP BACK TO LOOP .END |
Topic | Author | Date |
AT89C51 countdown timer | 01/01/70 00:00 | |
I Think... | 01/01/70 00:00 | |
Decimal Counting down | 01/01/70 00:00 | |
if you post errors | 01/01/70 00:00 | |
it seems to be non-51 | 01/01/70 00:00 | |
aha | 01/01/70 00:00 | |
I screwed up | 01/01/70 00:00 | |
we just wanted to run down on somebody :-) | 01/01/70 00:00 | |
This group | 01/01/70 00:00 | |
BCD=IncrementByAdding01HDecByAdding99H | 01/01/70 00:00 | |
RTFB | 01/01/70 00:00 | |
Why count BCD down? | 01/01/70 00:00 | |
Why microcontroller? | 01/01/70 00:00 | |
The Appliction![]() | 01/01/70 00:00 | |
Why count BCD down? | 01/01/70 00:00 |