''This is as far as I have got. I know it is not much. I am having great dificulty in breaking down
'' the elements of the I2CWrite. I get a lit up display and that is all. Any help would be greatly ''appreciated.
'************************************************* **********************
'* Pic16f628 LCD I2C 01 260110 *
'* Display output to LCD of Something Readable *
'* Display lights Nothing else *
'* *
'* Internal Oscillator *
'* *
'************************************************* **********************
#CONFIG
cfg = _FOSC_INTOSCCLK ; INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
; _FOSC_ERCLK _ER_OSC_CLKOUT _FOSC_ERIO
; _ER_OSC_NOCLKOUT _FOSC_INTOSCCLK _INTRC_OSC_CLKOUT
; _FOSC_INTOSCIO _INTRC_OSC_NOCLKOUT _FOSC_ECIO
; _EXTCLK_OSC _FOSC_HS _HS_OSC _FOSC_XT
; _XT_OSC _FOSC_LP _LP_OSC
cfg&= _WDT_ON ; WDT enabled (MUST USE CAPS)
cfg&= _WDTE_OFF ; WDT disabled
cfg&= _PWRTE_ON ; PWRT disabled (MUST USE CAPS)
cfg&= _MCLRE_OFF ; RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD
cfg&= _LVP_OFF ; RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming
cfg&= _BOREN_OFF ; BOD Reset disabled
cfg&= _CPD_OFF ; Data memory code protection off
cfg&= _BODEN_OFF ; BOD Reset disabled
cfg&= _CP_OFF ; Code protection off
__CONFIG cfg
#ENDCONFIG
DEFINE OSC 4
define I2C_SLOW 1
DEFINE I2C_INTERNAL 1
'#define I2C_SLOW 1 ' Not sure if it gets #
'#DEFINE I2C_INTERNAL 1 ' Not sure if it gets #
TrisB = 0
SDA VAR PORTB.1 'SDA Pin#7 on Pic16f628
SCL VAR PORTB.2 'SCL Pin#8 on Pic16f628
Five var PORTB.5 'Pin#11 LED Output to indicate program is running
Tim var byte ' Variable for Time
Tim =500
Tim2 var byte ' Variable for Time
Tim2 =40
Control Var byte
Control = %10100000 'Page 157 PBP Control byte would be %10100000 or $A0
Address var byte 'LCD address:With Arduino I2C Scan Program 39 Dec or 0x27 Hex
Address = 39 'LCD address:With Arduino I2C Scan Program 39 Dec or 0x27 Hex
Main:
I2CWRITE SDA,SCL,Control,[$00,$01]'clear display
pause Tim2
I2CWRITE SDA,SCL,Control,[$00,$0C]'display on/off
pause Tim2
' Don't know where the below $FE,$50,$04,$0A,$15,$0E,$04,$0A,$0A,$00]
' are from they were copied from another program.
I2CWRITE SDA,SCL,Control,[Address,$FE,$50,$04,$0A,$15,$0E,$04,$0A,$0A,$00]' Hello
pause Tim2
low Five 'This is to see that the program is running It does Blink
pause Tim
high Five
pause Tim
low Five
Goto Main
END


Reply With Quote

Bookmarks