I've purchased 2 LCD03 displays. They both work great when displaying data with I2C.
When i try to receive data from the keyboard however, i have to get 2 bytes, 1 from register 1 and 1 from register 2
They also (almost) present the right bits, eg. when pressing '5' the fifth bit is set of the low byte; perfectly correct!!!
So far so good, but...
On both bytes i receive (the high byte on reg 2 and the low byte on reg 1) the Most Significant Bit is set: "10000000" and "10000000".
This is even the case when there is no key pressed at all.
This way the '8'-key gets lost because this IS the MSB of the low byte which is (in my opinion incorrectly) always set.
Am i doing something wrong? or is there another explanation or workaround?
I'm using Crownhill Proton+ PicBasic with an 16f628; i've terminated the I2C bus with two 2k2 resistors.
The keyboard is the one you sell on the website.
Both displays give exactly the same results......
- Code: Select all
CONFIG INTRC_OSC_NOCLKOUT, MCLRE_ON, LVP_OFF, WDT_OFF, PWRTE_ON, CP_OFF, BODEN_OFF
;DECLARE optimiser_level = 6
ALL_DIGITAL TRUE ; All inputs digital
DIM KeyLow AS BYTE
DIM Integer AS BYTE
DIM IntegerStr AS BYTE ; Create a byte array to hold converted value, and NULL terminator
SYMBOL I2Caddr = $C6 ; Targetaddress of the display
SYMBOL SDA = PORTB.2 ; Alias the SDA (Data) line
SYMBOL SCL = PORTB.1 ; Alias the SSL (Clock) line
WHILE 1 = 1
; Just the low byte; the high byte has exactly the same problem
I2CIN SDA, SCL, I2Caddr, 1, [KeyLow]
; BUSIN I2Caddr,2,[KeyLow] ; !!!!! tried this as well !!!!!!
Integer = KeyLow
STRN IntegerStr = STR$(BIN Integer ) ; Convert the Integer to a STRING
I2COUT SDA, SCL, I2Caddr, 0, [ 3, 4, 1, STR IntegerStr \9] ; Cursor to line 3 pos 1 and print result
I'm really hoping you have an answer to this!!!
Many thanks in advance,
Hans van Neck