Onlangs kocht ik een 2x16 OLED display EA W162-X3LG wat volgens datasheet HD44780 compatibel is. Dus dacht ik om het goed werkend LCD te wisselen met die OLED maar er verschijnt enkel random leestekens op het scherm. Met het LCD display werkt het programma perfect en faalt de uilezing nooit. Hardwarematig is de OLED pin compatible en volgens de datasheet is de code ook hetzelfde maar het initialiseren loopt fout volgens mij. Heeft er iemand ervaring hiermee. Ik gebruik een PIC16F887 op 4MHz samen met MIKROELECTRONIKA ontwikkelboard EASYPIC5. Het is mogelijk om assembler tussen de code te plaatsen
- Code: Select all
' Lcd module connections
dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
' End Lcd module connections
main:
TRISB = 0
PORTB = 0xFF
TRISB = 0xFF
PORTC = 0x0F
TRISC = 0x0F
INTCON = 0
ANSEL = %00000011 ' Configure AN pins as digital I/O
TRISA = 0xFF
ANSELH = 0
Lcd_Cmd(_LCD_CURSOR_OFF)
Lcd_Cmd(_LCD_CLEAR)
txt1 = " Milli-Volt PSU "
txt2 = "***************"
txt3 = "1=00000 2=00000"
txt4 = "06* 05* 26* 28*"
Lcd_Init() ' Initialize Lcd
Lcd_Cmd(_LCD_CLEAR) ' Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off
Lcd_Out(1,1,txt1) ' Write text in first row
Lcd_Out(2,3,txt2) ' Write text in second row
Delay_ms(2000)
Lcd_Cmd(_LCD_CLEAR) ' Clear display
Lcd_Out(1,1,txt3) ' Write text in first row
Lcd_Out(2,1,txt4) ' Write text in second row
VRCON = %00010000 ' Vref extern
ADCON1 = %10110000 ' right justified en Vref extern
TRISA = 0xFF ' All ports input
Delay_ms(2000) ' Wait 2 sec
