there are a number of issues here
Code:
#CONFIG
;cfg = _FOSC_INTOSCCLK ; INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN do you really need clockout on RA6
cfg = _INTRC_OSC_NOCLKOUT ;INTRC 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 ;error not correct or needed
#ENDCONFIG
Code:
DEFINE OSC 4
;define I2C_SLOW 1 not relevant
;DEFINE I2C_INTERNAL 1 incorrect
'#define I2C_SLOW 1 ' Not sure if it gets #
'#DEFINE I2C_INTERNAL 1 ' Not sure if it gets #
TrisB = 0 ; i2c pins should not be set as outputs
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 a byte cannot hold such a large number byte range 0 to 255
Tim var word ' Variable for Time
Tim =500
Tim2 var byte ' Variable for Time
Tim2 =40
;Control Var byte ; the example in manual is for an eeprom , there is no eeprom here
;Control = 100000 'Page 157 PBP Control byte would be 100000 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
; arduino i2c address is a 7 bit address pbp uses an 8 bit address
Address = Address <<1 ; convert to 8 bit
I2CWRITE SDA,SCL,Address ,[$00,$01]'clear display
pause Tim2
I2CWRITE SDA,SCL,Address ,[$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. they come from the Darrel Taylor LCD_PCF8574A.pbp i2c lcd include file and are pointless here
I2CWRITE SDA,SCL,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 at twice the expected rate due to incorrect var type
pause Tim
high Five
pause Tim
low Five
Goto Main
the lcd has not been initialized
nor have you sent the lcd data in a nibblised format with correct strobe pulses being generated
its much simpler to use the Darrel Taylor LCD_PCF8574A.pbp i2c lcd include
there are plenty of example in the links given
Bookmarks