Code:
'PIC 16F1824
#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01101010 'sets the internal oscillator to 4Mhz
TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000
OPTION_REG.7 = 0
WPUA = %00000000
WPUC = %00000011
PORTA = 0
PORTC = 0
SCL VAR PORTC.0
SDA var PORTC.1
RS var PORTC.2
symbol mode = $7C
pause 100
RS = 0
'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)
'=============Initializing by Instruction==========pag 39 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave
I2CWRITE PORTC.1, PORTC.0,$7C,[$00] 'send command to display
'FUNCTION SET 0 and 1 ------------pag 30 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
pause 10
I2CWRITE PORTC.1, PORTC.0,$7C,[$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
pause 10
'INTERNAL OSC------------pag 35 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$14] ' 1/5 BIAS , 130Hz/5v
'CONTRAST SET------------pag 37 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$73]
'POWER/ICON/CONTRAST------pag 36 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$5E] 'ICON=ON, BON = OFF , contrast $03
'FOLLOWER CONTROL-------pag 37 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$6D] 'FON=1 ..set is correct ??
pause 10
'DISPLAY ON------------- pag 29 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$0C] 'display ON, cursor ON, blink OFF
'CLEAR LCD --------------pag 28 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$01]
'ENTRY MODE SET----------
I2CWRITE PORTC.1, PORTC.0,$7C,[$06] 'cursor/blink moves to right and DDRAM address is increased by 1.
RS = 1
pause 500
I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave
I2CWRITE PORTC.1, PORTC.0,$7C,[$40] 'Write to display RAM
I2CWRITE PORTC.1,PORTC.0,$7C,["HELLO"] 'print on the first line [ I am not sure this line will work]
end
Bookmarks