help for 1second timer

Discussion in 'Embedded Systems and Microcontrollers' started by dileepchacko, Aug 23, 2008.

  1. dileepchacko

    Thread Starter Active Member

    May 13, 2008
    102
    1
    Hi All

    I am very new to micro controller 8051. I want to generate a 1second time delay in assembly language for 8051 micro controller. This time delay is for making a digital clock using 8051. Can anybody help me to write a code for generating an 1second time delay in assembly language.
     
  2. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    ; 8051 on 12MHz
    ; Initialise timer 1 and run it
    MOV TMOD,#10H

    MOV R1,#20D
    ABC:
    MOV TH1,#3CH
    MOV TL1,#B0H
    SETB TR1
    WAIT:
    JNB TF1,WAIT ; Timer overflow in 50ms
    CLR TF1
    DJNZ R1,ABC ; Loop 20 times

    There will be some inaccuracies in term of usec because
    the program ignore time taken to execute the instructions.
     
  3. amolhshah

    Member

    Aug 12, 2008
    13
    1
Loading...