Hello,

I am in the process of connecting a keypad to an i2c port expander
(PCF8574A) to an UNO and have run into the following problem. More
than likely the problem is my lack of understanding. Writing to the
port expander appears to be no problem. Reading from it using i2c.>n
results in the UNO hanging. Writing zero bytes and then reading 1 byte
using i2c.m>n appears to read the port expander correctly (i.e. 1 0
$38 i2c.m>n). What am I missing? Edited minicom session below.

Best wishes and thanks,
Tristan

amforth 6.3 ATmega328P Forthduino
> i2c.init.default
 ok
> i2c.detect
      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
 0:                       -- -- -- -- -- -- -- -- --
10:  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20:  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30:  -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- --
40:  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50:  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60:  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70:  -- -- -- -- -- -- -- --                        
 ok

# turns on each LED attached to the port expander (ports sinking)
> $00 1 $38 i2c.n>
 ok

# turns off each LED attached to the port expander
> $ff 1 $38 i2c.n>
 ok

# this hangs the UNO
> 1 $38 i2c.>n
 
# (repeating all comands except the one above)
# this reads the port expander address and leaves $ff on the stack
> 1 0 $38 i2c.m>n
 ok

 

 

 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to