3-Draht Interface für Standard LCD-Module

Diese Schaltung ist ein einfaches 3-Draht Interface für Standard HD44780 und kompatible LCD-Text-Module. Die Codebeipiele enthalten nur die Teile, die direkt das Display ansteuern.
Anstelle des HCT164 kann auch ein LS164 genommen werden.


Schaltplan des Interface

Quellcode für Microchip PIC Controller.


; Microchip PIC @ 4MHz
;------------------------------------------------------------------------
;Variblen		
  LCD_SERDATA	; Serielle Daten LCD	
  LCD_BITCNT    ; Bitcounter LCD
  LCD_RS        ; RS Flag  bit 0
;------------------------------------------------------------------------
; LCD pins
#define	  LCD_DATA   PORTB,1
#define	  LCD_CLK	 PORTB,2
#define	  LCD_ENABLE PORTB,3
;------------------------------------------------------------------------
;
; 8 Bit ans LCD plus ENABLE & RS
;
LCD_SER_SEND
        movwf LCD_SERDATA	
        bcf   LCD_ENABLE	
        bcf   LCD_DATA	
        movlw 0x08	
        movwf LCD_BITCNT
slcd1   btfsc LCD_SERDATA,7    ; highbit data
        bsf   LCD_DATA  
        bsf   LCD_CLK          ; clock impuls
        bcf   LCD_CLK
        bcf  	LCD_DATA
        rlf	  LCD_SERDATA,f    ; daten links rotieren
        decfsz LCD_BITCNT,f    ; 8 bit fertig ?
        goto  slcd
        btfsc LCD_RS,0
        bsf   LCD_DATA         ; rs high
        nop
        bs    LCD_ENABLE
        nop
        bcf   LCD_ENABLE
        return

Quellcode für Atmel AVR Controller.


; AVR @ 4MHz
.equ	lcd_e		= 0
.equ	lcd_cl		= 1
.equ	lcd_da_rs	= 2
.equ	lcd_port	= PORTC
.equ	lcd_pddr	= DDRC
.def	loop_cnt_1	= r19		; loop counter
.def 	loop_cnt_2	= r20		; help
.def	lcd_data 	= r22		; daten für lcddisplay

;***************************************************************************
;*
;*	func:	lcd_out_c
;*		lcd_out_d
;*
;*	vars:	lcd_data
;*		loop_cnt_1
;*		
;*	subs:	wait_x_100u
;*
;***************************************************************************
lcd_out_c:
        push	loop_cnt_1
        delay_x_100u 2
        rcall	lcd_out8
        cbi	lcd_port,lcd_da_rs
        rjmp	lcd_en
lcd_out_d:
        push	loop_cnt_1
        delay_x_100u 2
        rcall	lcd_out8
        sbi	lcd_port,lcd_da_rs
        rjmp	lcd_en
lcd_en:
        sbi	lcd_port,lcd_e
        pop	loop_cnt_1
        cbi	lcd_port,lcd_e
        ret

lcd_out8:
        ldi	loop_cnt_1,8
rorloop: rol	lcd_data
        brcs	eout
        cbi	lcd_port,lcd_da_rs		
        rjmp	edo
eout:   sbi	lcd_port,lcd_da_rs
edo:    sbi	lcd_port,lcd_cl
        cbi	lcd_port,lcd_cl
        dec	loop_cnt_1
        brne	rorloop
        ret

;***************************************************************************
;*
;*	func:	wait_x_100u
;*
;*	vars:	loop_cnt_1
;*		loop_cnt_2
;*
;***************************************************************************
wait_x_100u:
        push	loop_cnt_2
        mov	loop_cnt_2,loop_cnt_1
l2loop: ldi 	loop_cnt_1,199			; 99
lcloop: dec	loop_cnt_1
        or	loop_cnt_1,loop_cnt_1
        brne	lcloop
        dec	loop_cnt_2
        or	loop_cnt_2,loop_cnt_2
        brne	l2loop
        pop	loop_cnt_2
        ret
        

  © Robert Rottmerhusen 2010  ♦  Update: 2010-01-17  ♦  feedback☺rottmerhusen.com up English Deutsch