Ciao!
Ho fatto un programmino di prova (in verità scopiazzato in parte) per un display Displaytech 162B che mi ha regalato un mio amico. L'ho collegato (ma perché non usano una interfaccia standard??) e..... non funge nulla! Ho naturalmente già collegato il pot da 1K per il contrasto ed infatti riesco a regolarlo in maniera corretta, ma secondo me non si inizializza nemmeno, infatti rimane la sola prima riga e la seconda non c'è verso che si accenda!!
Posto anche il sorgente, anche se qualsiasi modifica gli viene fatta non sortisce a nessun risultato "visivo".
PROCESSOR 16F84A RADIX DEC ERRORLEVEL -302 INCLUDE "P16F84A.INC" __CONFIG _XT_OSC & _CP_OFF & _WDT_OFF
;LCD Control lines
LCD_RS equ 2 ;Register Select LCD_E equ 3 ;Enable
;LCD data line bus
LCD_DB4 equ 4 ;LCD data line DB4 LCD_DB5 equ 5 ;LCD data line DB5 LCD_DB6 equ 6 ;LCD data line DB6 LCD_DB7 equ 7 ;LCD data line DB7
ORG 0CH
tmpLcdRegister res 2 msDelayCounter res 2
;Reset Vector
ORG 00H Start bsf STATUS,RP0 ;Commuta su bank 1
movlw 00011111B ;Imposta le linee I/O della PORTA movwf TRISA
movlw 00000011B ;Imposta le linee I/O della PORTB movwf TRISB ;impostando come uscite solo le ;linee connesse al display
bcf STATUS,RP0 ;Commuta sul bank 0 clrf PORTA clrf PORTB
;Inizializzazione del display call LcdInit
; Cursor home movlw B'00000010' call LcdSendCommand
movlw 'C' call LcdSendData
Loop goto Loop
;********************************************************************** ; Delay subroutine ; ; W = ritardo in ms (clock = 4MHz) ;**********************************************************************
msDelay movwf msDelayCounter+1 clrf msDelayCounter+0
; 1 ms (about) internal loop msDelayLoop nop decfsz msDelayCounter+0,F goto msDelayLoop nop
decfsz msDelayCounter+1,F goto msDelayLoop
return
;********************************************************************** ; Init LCD ; Routine di inizializzazione del display LCD ;**********************************************************************
LcdInit ; Wait for more than 15ms after Vdd rises to 4.5V movlw D'050' call msDelay bsf PORTB, LCD_DB4 bsf PORTB, LCD_DB5 bcf PORTB, LCD_DB6 bcf PORTB, LCD_DB7 call Enable ; Wait for more than 4,1ms movlw D'006' call msDelay call Enable
; Wait for more than 100us movlw D'001' call msDelay call Enable ; Interfaccia a 4 bit, display a 2 linee, caratteri 5X7 movlw B'00101000' call LcdSendCommand ; Increment, no shift movlw B'00000110' call LcdSendCommand ; Display on, Cursor on, blinking on movlw B'00001111' call LcdSendCommand ; Clearing display ;call LcdClear
; We have finished!! return
;********************************************************************** ; Clear LCD ;**********************************************************************
LcdClear movlw B'00000001' call LcdSendCommand ; Wait for more than 1,64ms movlw D'003' call msDelay
;DD RAM address set 1st digit movlw B'10000000' call LcdSendCommand
return
;********************************************************************** ; Invio di un dato al display ;**********************************************************************
LcdSendData
bsf PORTB,LCD_RS call LcdSendByte return
;********************************************************************** ;Invio di un comando al display ;**********************************************************************
LcdSendCommand bcf PORTB,LCD_RS call LcdSendByte return
;********************************************************************** ; Invio di un byte al display su bus a 4 bit ;**********************************************************************
LcdSendByte ;Salva il byte da inviare movwf tmpLcdRegister
;invio dei 4 bit più significativi clrf PORTB btfsc tmpLcdRegister,4 bsf PORTB,LCD_DB4 btfsc tmpLcdRegister,5 bsf PORTB,LCD_DB5 btfsc tmpLcdRegister,6 bsf PORTB,LCD_DB6 btfsc tmpLcdRegister,7 bsf PORTB,LCD_DB7 call Enable
;Invio dei 4 bit meno significativi clrf PORTB btfsc tmpLcdRegister,0 bsf PORTB,LCD_DB4 btfsc tmpLcdRegister,1 bsf PORTB,LCD_DB5 btfsc tmpLcdRegister,2 bsf PORTB,LCD_DB6 btfsc tmpLcdRegister,3 bsf PORTB,LCD_DB7 call Enable return
Enable bsf PORTB, LCD_E movlw D'002' call msDelay bcf PORTB, LCD_E movlw D'002' call msDelay return
END
Ciao, grazie!!