Showing posts with label 7 segment interfacing with 8051. Show all posts

program for 7 segment display interfaced with microcontroller 8051 (4 digit)



org 00h

dig_ctrl4 equ p1.0

dig_ctrl3 equ p1.1

dig_ctrl2 equ p1.2

dig_ctrl1 equ p1.3

mov dptr,#200h

mov r0,#00d

ljmp main

org 000Bh

mov tl0,#36h

mov th0,#0f6h

mov p2,#0ffh

clr dig_ctrl1

clr dig_ctrl2

clr dig_ctrl3

clr dig_ctrl4

inc r0

mov a,r0

mov b,#4

div ab

mov r0,b

cjne r0,#00,b1      ;check for remainder

mov dptr,#200h

mov a,r1

movc a,@a+dptr

mov p2,a

setb dig_ctrl1

sjmp last

b1: cjne r0,#01,b2

mov dptr,#200h

mov a,r2

movc a,@a+dptr

mov p2,a

setb dig_ctrl2

sjmp last

b2: cjne r0,#02,b3

mov dptr,#200h

mov a,r3

movc a,@a+dptr

mov p2,a

setb dig_ctrl3

sjmp last

b3: cjne r0,#03,last

mov dptr,#200h

mov a,r4

movc a,@a+dptr

mov p2,a

setb dig_ctrl4

last:

reti





main: mov tmod,#11h

mov tl0,#36h

mov th0,#0f6h

mov ie,#82h

setb tr0

again: mov r4,#00

l4: mov r3,#00

l3: mov r2,#00

l2: mov r1,#00

l1: acall delay

inc r1

cjne r1,#10,l1

inc r2

cjne r2,#10,l2

inc r3

cjne r3,#10,l3

inc r4

cjne r4,#10,l4

sjmp again



delay: mov r5,#20                            ;initialize counter for delay

rpt: mov tl1,#0fdh           ;initialising timer for delay

mov th1,#4bh

setb tr1

here: jnb tf1,here

clr tr1

clr tf1

djnz r5,rpt

ret



org 200h

db 40h,0f9h,24h,30h,19h,12h,02h,0f8h,00h,10h

4 digit 7 segment display interfacing with 8051

  

If we have to interface 4 seven segment display to 8051 then it requires 8x4=32 pins. But think we have to connect more than 4 then how we will connect. We now have a great solution. We will use only 8 pins of microcontroller to interface them. But the thing is that how each and every segment displays different data. 
I wanna tell you that only one segment glow at a time. It is possible with the control pin you can see in the figure named 1,2,3,4. We set a small timing for each segment that a human eye cannot detect by using delay routine. So the main task in this interfacing is to set timing.


CLICK HERE TO SEE PROGRAM IN ASSEMBLY LANGUAGE

- Copyright © Microcontroller Projects -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -