8051 assembly code to generate triangular wave



ORG 0
CLR A
UP:INC A
MOV P2,A
CJNE A,#0FFH,UP
LCALL DELAY
DOWN: DEC A
MOV P2,A
CJNE A,#00,DOWN
LCALL DELAY
SJMP UP


END

Comments

  1. What type of delay could you use here,
    I thought
    Timer 0 Mode 2 in an 8051

    DELAY:
    MOV TH0,#0F9H

    SETB TR0
    HERE: JNB TF0,HERE
    CLR TF0

    ReplyDelete
    Replies
    1. DELAY:H2:MOV R0,#12H;
      H1: MOV R1,#0F7H;
      MOV R2,# 0FFH;
      AGAIN : DJNZ R2, AGAIN;
      DJNZ R1, H1;
      DJNZ R0,H2;
      RET;

      Delete

Post a Comment