Maker Pro
Maker Pro

blink led

I want to blink led for some time
I made diagram using proteus
component
AT89C51
crystal
LED

diagram


assembly code

Code:
       org 00h
    
      Setb P1.0          ; Led on
      clr   P1.0           ; Led off
     
       delay:
    mov    R1, #20
    mov    R2, #0
delay1:    djnz    R2, delay1
    djnz    R1, delay1
  
   ret
   end

Q but Led is not blinking ?
 

KrisBlueNZ

Sadly passed away in 2015
Hardware errors:
  1. C3 should be higher than 1 nF. I suggest 100 nF.
  2. Add a pulldown resistor of around 10k from pin 9 to 0V.
  3. R2 must connect to VCC, not 0V.
  4. R2 must be a lot lower than 500k. For example try 470Ω.
Firmware errors:
  1. You need to insert delays between the instructions that change the LED state.
  2. You need to make the LED state logic into a continuous loop, using a label at the start and an RJMP at the end.
Code:
        ORG     0

MainLoop:
        setb    P1.0                    ; Turn LED ON
        rcall   Delay                   ; Wait a short time
        clr     P1.0                    ; Turn LED OFF
        rcall   Delay                   ; Wait a short time
        rjmp    MainLoop                ; Loop forever

Delay:
        mov     R1,#20                  ; Set up outer loop count
        mov     R2,#0                   ; Set up inner loop count
Delay1: djnz    R2,Delay1               ; Inner loop
        djnz    R1,Delay1               ; Outer loop
        ret

        end
 

KrisBlueNZ

Sadly passed away in 2015
You've removed the pushbutton, and C3, and the connection to pin 31. Put those all back like in your diagram in post #1. You don't need R1 though. Actually I think R1 was supposed to be connected to pin 9 but you connected it to pin 31 instead.
 
Top