wijnendael
Member
Now on my next learn process and attempting to understand the use of I2C communication but require a little help. I have a PCF8574P and a 4x4 matrix membrane keypad that i am trying to get to communicate with a picaxe 08M2 but not having much success at the moment below is the code i am using and a schematic of my circuit can somebody point out where i am going wrong.
Code:
;picaxe 08M2
;SCL connected to pin6 C.1
;SDA connected to pin5 C.2
;INT not connected
;A0-A2 connected to +5V for slave address 01001111 (read)
;LCD module connected to pin7 C.4
symbol keyint=pin3
symbol key=b1
setfreq m16
MAIN:
;debug
if keyint = 0 then PCF8574_read ;interupt from PCF8574P when key is pressed
goto main
PCF8574_read:
i2cslave %01001111, i2cslow, i2cbyte ; setup i2c to read from pcf8574
pause 1000
readi2c (key)
pause 1000
sertxd (#key)
serout c.4, n2400_8, (254,1)
serout c.4, n2400_8, (254,128, #key)
select case key ;checked for key pressed on 4x4 keypad
case is $87 goto main ;key 1
case is $84 goto main ;key 2
case is $82 goto main ;key 3
case is $48 goto main ;key 4
case is $44 goto main ;key 5
case is $42 goto main ;key 6
case is $28 goto main ;key 7
case is $24 goto main ;key 8
case is $22 goto main ;key 9
case is $30 goto menu ;key *
case is $12 goto main ;key #
case is $81 goto raisevolts ;key A
case is $41 goto lowervolts ;key B
case is $21 goto machine ;key C
case is $11 goto type ;key D
else goto main
end select
goto PCF8574_write
PCF8574_write:
i2cslave %01001110, i2cslow, i2cbyte ;setup i2c to write to pcf8574
; code here if required
goto main
menu: ;display menu on lcd
;insert code here for menu
goto main
raisevolts: ;increase output volts
;insert code for increasing voltage here
goto main
lowervolts: ;lower output volts
;insert code for lowering volts here
goto main
machine: ;select pulsed or fixed
;insert code for selecting pedal type here
goto main
type: ;select line or shade
;insert code for selecting machine type here
goto main