امروز برابر است با :1 آذر 1403

Atmel AT89C2051 LCD sample project

Atmel AT89C2051 LCD sample project

نمونه در  ادامه مطلب.

Atmel AT89C2051 LCD sample project

horizontal line

This shows how to interface an Hitachi 2×16 LCD display to a 2051. To minimise the usage of processor pins the LCD will be driven in 4 bit mode.

 

photo of LCD project running sample program

LCD project running sample program.

 

photo of LCD mounted on a 1 inch prototype board

LCD mounted on a 1 inch prototype board. A DT004 is used as a mother board and a DT104 is used as the processor board.

 

 

circuit of the Simmbus to LCD interface

Circuit of the Simmbus to LCD interface

 

 

photo of mounting of the LCD 14 pin single inline header connector

Mounting of the LCD 14 pin single inline header connector to a Dontronics 1 inch prototype board. The connections from the LCD connector to the Simmbus is done on the back of the board.

 

 

photo of the pot is for LCD contrast

The pot is for LCD contrast.

 

 

photo of back view showing jumpers

Back view showing jumpers.

It is also possible to use this adaptor board and a DT004 to interface the LCD to a computer parallel port.

 

Sample program used to get the display shown above in the photos.

;Written by Peter Averill
;LCD demo program
;
$mod2051 
CR          EQU   0dh          ; carriage return
LF          EQU   0ah          ; line feed
;lcd equates
rs          equ   p1.2
en          equ   p1.3
db4         equ   p1.4
db5         equ   p1.5
db6         equ   p1.6
db7         equ   p1.7
count       equ   r0
datcom      bit   0
            DSEG  AT 0020H
            ORG   0030H        ; stack origin
stack:      DS    20H          ; stack depth
;
            CSEG
            ORG   0000H        ; power on/reset vector
            Jmp   cold_start
            ORG   0003H        ; external interrupt 0 vector
            Reti               ; undefined
            ORG   000BH        ; timer 0 overflow vector
            reti
            ORG   0013H        ; external interrupt 1 vector
            Reti               ; undefined
            ORG   001BH        ; timer 1 overflow vector
            reti               ; undefined
            ORG   0023H        ; serial I/O interrupt vector
            reti
;
            ORG   40H          ; begin constant data space
setup:      DB    033h,032h,028h,00eh
            db    002h,001h,0ffh
mess:       db    'Victoria Uni',0ffh
mess1:      db    'Electronics',0ffh
;
;
            USING  0           ; register bank zero
cold_start:
            mov   sp, #(stack-1) ; initialize stack pointer
            mov   a,#0ffh
            call  delay_ms
            clr   datcom       ;send commands
            mov   dptr, #setup ;lcd setup string
            call  send_string
            setb  datcom       ;send data
            mov   dptr, #mess
            call  send_string
            mov   a,#0c0h      ;select second row of lcd
            clr   datcom       ;send command
            call  send_char
            mov   dptr, #mess1
            setb  datcom       ;send data
            call  send_string
repeat:
            jmp   repeat
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
send_string:
; Transmit string pointed to by DPTR.
; String may be of any length, but must be null-terminated.
            Push  acc
            push  dpl
            push  dph
ss1:
            clr   a
            movc  a, @a+dptr  ; get character
            inc   a
            jz    ss2          ; check for terminator
            dec   a
            call  send_char    ; send character
            inc   dptr         ; point to next character
            jmp   ss1
ss2:
            pop   dph
            pop   dpl
            pop   acc
            ret
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
send_char:  mov   c,datcom
            mov   rs,c
            clr   en
            mov   c,acc.4
            mov   db4,c
            mov   c,acc.5
            mov   db5,c
            mov   c,acc.6
            mov   db6,c
            mov   c,acc.7
            mov   db7,c
            setb  en
            clr   en
            push  acc
            mov   a,#4h
            call  delay_ms
            pop   acc
            mov   c,acc.0
            mov   db4,c
            mov   c,acc.1
            mov   db5,c
            mov   c,acc.2
            mov   db6,c
            mov   c,acc.3
            mov   db7,c
            setb  en
            clr   en
            mov   a,#4h
            call  delay_ms
            ret
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delay_ms:
; Delay for one mS times the value in the accumulator.
            Push  acc
            push  b
            mov   b, #0
dd:
            djnz  b, $         ; 500 uS @ 12 MHz
            djnz  b, $         ; 500 uS @ 12 MHz
            djnz  acc, dd
            pop   b
            pop   acc
            ret
;
            end
اشتراک گذاری