I am trying to get a 16F887 to communicate with the LCD backpack from web4robot working over I2C and can not for the life of me figure it out. This is my first go at I2C and have been working on it for the past few days. Please take a look at my code and point me in the right direction. Both the data and clock pin seems to be stuck high.
Code:
'COMMANDS
'Prefix Command Parameter Description
'$FE $00 null No operation
'$FE $01 1 Byte Changing the I2C Slave Address
'$FE $02 1 Byte Changing BAUD Rate
'$FE $03 1 Byte Set Backlight Brightness
'$FE $04 1 Byte Set Contrast
'$FE $05 None Save Splash/Startup Screen
'$FE $06 None Display Firmware Version Number
'$FE $07 None Display Serial Baud Rate
'$FE $08 None Display I2C Address
'$FE $09 Null No operation
'$FE $0A None Turn ON Display
'$FE $0B None Turn Off Display
'$FE $0C 2 bytes Set Cursor Position
'$FE $0D None HOME Cursor
'$FE $0E None Turn ON Underline Cursor
'$FE $0F None Turn Off Underline Cursor
'$FE $10 None Move Cursor Left One Space
'$FE $11 None Move Cursor Right One Space
'$FE $12 None Turn ON Blinking Cursor
'$FE $13 None Turn Off Blinking Cursor
'$FE $14 None Clear Screen
'$FE $15 Variable Print String
'$FE $16 1 Byte Init Horizontal Bar Graph
'$FE $17 4 bytes Draw Horizontal Bar Graph
'$FE $18 None Init Vertical Bar Graph
'$FE $19 4 bytes Draw Vertical Bar Graph
'$FE $1A 9 bytes Load Custom Characters
'$FE $1B None READ Keypad
Include "modedefs.bas"
OSCCON = %01110001 'Int CLK 8MHz
ANSEL = 0
ANSELH = 0 'All digital
ADCON1 = 7
DEFINE OSC 8 '8MHz
TRISA = %00000000
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
TRISE = %000
CPIN var PortC.3
DPIN var PortC.4
'ADDRESS = $4C
Main:
pause 2000 ' lcd start up
i2cwritE DPIN, CPIN, $4C,[$FE, $04, 99],NOACK 'Sets contrast (0-100)
PAUSE 100
i2cwritE DPIN, CPIN, $4C,[$FE, $03, 200], NOACK 'Sets the brightness (0-250)
PAUSE 200
i2cwritE DPIN, CPIN, $4C,["Hello World!"], NOACK 'text sent to the LCD, defaults to row 0, col 0
PAUSE 1500
'Next is to make sure all of above worked
HIGH PORTD.2
PAUSE 250
LOW PORTD.2
PAUSE 250
HIGH PORTD.2
PAUSE 250
LOW PORTD.2
PAUSE 250
HIGH PORTD.2
PAUSE 250
LOW PORTD.2
PAUSE 250
HIGH PORTD.2
PAUSE 250
LOW PORTD.2
goto main
NOACK:
HIGH PORTD.2
PAUSE 5000
LOW PORTD.2
PAUSE 1000
end
Bookmarks