Forum Replies Created
Viewing 1 post (of 1 total)
-
AuthorPosts
-
nitesh sinhaParticipant
i am doing distance measurement using at89c51 and ultrasonic sensor but i m not getting anything on the seven-segment display ,i am using three seven-segment display ,the code is given below
ORG 00HMOV DPTR,#SSDisplay // moves the address of LUT to DPTRMOV P1,#00000000B // sets P1 as output portMOV P0,#00000000B // sets P0 as output portCLR P3.0 // sets P3.0 as output for sending triggerSETB P3.1 // sets P3.1 as input for receiving echoMOV TMOD,#00100000B // sets timer1 as mode 2 auto reload timerMAIN: MOV TL1,#210D // loads the initial value to start counting fromMOV TH1,#210D // loads the reload valueMOV A,#00000000B // clears accumulatorSETB P3.0 // starts the trigger pulseACALL DELAY1 // gives 10uS width for the trigger pulseCLR P3.0 // ends the trigger pulseHERE: JNB P3.1,HERE // loops here until echo is receivedBACK: SETB TR1 // starts the timer1HERE1: JNB TF1,HERE1 // loops here until timer overflows (ie;48 count)CLR TR1 // stops the timerCLR TF1 // clears timer flag 1INC A // increments A for every timer1 overflowJB P3.1,BACK // jumps to BACK if echo is still availableMOV R4,A // saves the value of A to R4ACALL DLOOP // calls the display loopSJMP MAIN // jumps to MAIN loopDELAY1: MOV R6,#2D // 10uS delayLOOP1: DJNZ R6,LOOP1RETDLOOP: MOV R5,#50D // loads R5 with 100DBACK1: MOV A,R4 // loads the value in R4 to AMOV B,#100D // loads B with 100DDIV AB // isolates the first digitSETB P1.0 // activates LED display unit D1ACALL DISPLAY // calls DISPLAY subroutineMOV P0,A // moves digit drive pattern for 1st digit to P0ACALL DELAY // 1mS delayACALL DELAYMOV A,B // moves the remainder of 1st division to AMOV B,#10D // loads B with 10DDIV AB // isolates the second digitCLR P1.0 // deactivates LED display unit D1SETB P1.1 // activates LED display unit D2ACALL DISPLAYMOV P0,A // moves digit drive pattern for 2nd digit to P0ACALL DELAYACALL DELAYMOV A,B // moves the remainder of 2nd division to ACLR P1.1 // deactivates LED display unit D2SETB P1.2 // activates LED display unit D3ACALL DISPLAYMOV P0,A // moves the digit drive pattern for 3rd digit to P0ACALL DELAYACALL DELAYCLR P1.2 // deactivates LED display unit D3DJNZ R5,BACK1 // repeats the display loop 100 timesRETDELAY: MOV R7,#250D // 1mS delayLABEL2: DJNZ R7,LABEL2RETDISPLAY: MOVC A,@A+DPTR // gets the digit drive pattern for the content in ARETSSDisplay: DB 0C0H // Hex code to display DISPLAY 0DB 0F9H // DISPLAY 1DB 0A2H // DISPLAY 2DB 0B0H // DISPLAY 3DB 99H // DISPLAY 4DB 94H // DISPLAY 5DB 84H // DISPLAY 6DB 0F8H // DISPLAY 7DB 80H // DISPLAY 8DB 90H // DISPLAY 9END -
AuthorPosts
Viewing 1 post (of 1 total)