| ??? 07/27/03 12:25 Read: times |
#51518 - RE: Tea Timer using led Responding to: ???'s previous message |
Hello Ralph,
The code below will control an LED on P1.0 that flashes every 10 secs approximately ( ON 10 secs OFF 10 secs ). But that accuracy is more than enough for timing Tea brewing. Well the timings apply for a 8052 running with a 12MHz crystal in 12 cycle mode ( each cycle = 1 microsecond )Modify the delay as needed by you. ( This is a sample code that I normally use for small delays. Typing it directly here - hence spelling errors MAY be there. Please assemble and check )
ORG 0000
jmp Main
ORG 100H
Main: clr P1.0 ; Always start with LED ON
Loop: mov DPTR, #10000 ; Load value for 10 secs.
call MsecDly
cpl P1.0 ; Control LED
jmp Loop ; Keep doing till reset
; MsecDly routine produces a delay of 1 x (value loaded in DPTR ) Milliseconds
; Call after loading DPTR with required delay in Secs x 1000
; Destroys B Register.
MsecDly: mov A,DPL
orl A,DPH ; DPTR*1000 microsec approx.
jz Exit
setb C
mov A,DPL
subb A,#0
mov DPL,A
mov A,DPH
subb A,#0
mov DPH,A
call SDly
jmp MsecDly
Exit: ret ; Delay over. Get back
SDly: mov B, #0C4H
nop
SDlyL: nop
nop
nop
djnz B,SDlyL
ret
Raghu |
| Topic | Author | Date |
| Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
| RE: Tea Timer using led | 01/01/70 00:00 | |
RE: Tea Timer using led | 01/01/70 00:00 |



