Inconsistency between I2CIN and I2COUT

Questions on control of serial busses
Post Reply
jmcdougall
Posts: 35
Joined: Tue Mar 22, 2022 11:17 pm

Inconsistency between I2CIN and I2COUT

Post by jmcdougall »

IOI have been testing multiple commands using ISCOUT without an issue. There has been no problem doping simple value assign to OUTlist with decimal values i.e. OUTlist(0) = 254 Note no quotes required around 254 even though OUTlist is defined as String

However when I try to do the same thing with OUTlist in I2CIN I get a compile errors for an expected string character.

Here is the sub I am trying to run to test keypad presses.


Sub GetKeypad(keypadchar)
Dim i as Integer
DIM LCD_CMD(8) as String
DIM LCD_DATA(16) as String

LCD_CMD(0) = 254
LCD_CMD(1) = 38 ' get last keypress value

i = 1

Do Until i = 30
I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)

print "Data0 = "; LCD_DATA(0)
print "Data1 = "; LCD_DATA(1)
print "Data2 = "; LCD_DATA(2)
print "Data3 = "; LCD_DATA(3)
print "Data4 = "; LCD_DATA(4)
print "Data5 = "; LCD_DATA(5)
print "Data6 = "; LCD_DATA(6)
print "Data7 = "; LCD_DATA(7)
print "Data8 = "; LCD_DATA(8)
print "Data9 = "; LCD_DATA(9)
print "Data10 = "; LCD_DATA(10)
print "Data11 = "; LCD_DATA(11)
print "Data12 = "; LCD_DATA(12)
print "Data13 = "; LCD_DATA(13)
print "Data14 = "; LCD_DATA(14)
print "Data15 = "; LCD_DATA(15)

If LCD_DATA(0) = "" then goto EXIT1
elseif LCD_DATA(0) = "a" then goto EXIT1
elseif LCD_DATA(0) = "b" then goto EXIT1
elseif LCD_DATA(0) = "c" then goto EXIT1
elseif LCD_DATA(0) = "d" then goto EXIT1
elseif LCD_DATA(0) = "e" then goto EXIT1
elseif LCD_DATA(0) = "g" then goto EXIT1
elseif LCD_DATA(0) = "h" then goto EXIT1
endif

wait(1000)
i = i + 1
Loop
EXIT1:
keypadchar = LCD_DATA(0)
print "keypad = ";keypadchar
RETURN

End Sub

And here is a sample of the error messages:

-ERROR F:/Enterprise Processor/test3.txt: 202: Expected End Of Line
Do Until i = 30
-WARNING I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-WARNING 203: Can only be initialized to 0
-WARNING I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-WARNING 203: Can only be initialized to 0
-WARNING I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-WARNING 203: Can only be initialized to 0
-WARNING I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-WARNING 203: Can only be initialized to 0
-ERROR F:/Enterprise Processor/test3.txt: 203: Expected string variable
I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-ERROR F:/Enterprise Processor/test3.txt: 203: Expected End Of Line
I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-W op=62,61d print "Data0 = "; LCD_DATA(0)
-ERROR F:/Enterprise Processor/test3.txt: 205: Unreachable statement
?? I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-W op=94,61d print "Data0 = "; LCD_DATA(0)
-ERROR F:/Enterprise Processor/test3.txt: 205: Unreachable statement
?? I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-W op=1a,61d print "Data0 = "; LCD_DATA(0)
-ERROR F:/Enterprise Processor/test3.txt: 205: Unreachable statement
?? I2CIN(10,11,80,2,LCD_CMD,16,LCD_DATA)
-W op=68,61d print "Data0 = "; LCD_DATA(0)

Do I have to put 254 as "254" and 38 as "38" or do I have to use their character equivalents



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Inconsistency between I2CIN and I2COUT

Post by basicchip »

Check the allowed syntax of the DO statement in the help files

DO UNTIL i=30

is not one of them

DO WHILE i <30

would be legal


"254" is 3 bytes of the ASCII characters 2,5 and 4

You should get an error with

CMD(0) = "254"

as that tries to assign multiple bytes to a single byte.

CMD = "254"

would be OK, though not what you really want.

jmcdougall
Posts: 35
Joined: Tue Mar 22, 2022 11:17 pm

Re: Inconsistency between I2CIN and I2COUT

Post by jmcdougall »

Yes I starting playing with the looping and the else if and changed the structure.

It is now working and I can retrieve the key press values successfully.

It looks like the other errors where causing the string issue.

About the only issue left to resolve is how to successfully send byte values as indicated in the other thread.

Thanks!

Post Reply