PhilTheFish
New Member
Hi all
I am new to this to excuse my lack of knowledge.
I have a PICAXE 20x2 which I have set to count pulses and store the value in the Scratchpad via put 1,b1 command.
I have set the PICAXE as an i2c slave and set the Raspberry Pi to connect to the i2c bus
I can see the PICAXE on the bus by using the i2cdetect -y 1 from the RPi.
The PIC is set to address 0x50
I can read values from the scratchpad by using the following RPi command
value=i2c.read_byte_data(0x50,0x01)
This reads the value of scratchpad location 0x01 and stores it in a variable called value.
the read only seems to work if I do the following code first
i2c.write_byte_data(0x50,0x00,0x00)
If i don't do this first then the value I read back is zero and not my count value.
I then tried to write a value to the scratchpad using the following RPi Command
i2c.write_byte_data(0x50,0x01,0x33)
This should write the value of 0x33 to location 0x01 in the scratchpad.
Here lies the problem.
It does not seem to write anything.
When I check the hi2cflag which should be set to 1 when a write event has taken place it is still set to 0.
Not sure i am doing this right and do not have any idea what I have done wrong.
Sorry if all this does not make any sense
Is there anyone out there that has had any experience of this.
any help would be useful
Many Thanks
Phil
I am new to this to excuse my lack of knowledge.
I have a PICAXE 20x2 which I have set to count pulses and store the value in the Scratchpad via put 1,b1 command.
I have set the PICAXE as an i2c slave and set the Raspberry Pi to connect to the i2c bus
I can see the PICAXE on the bus by using the i2cdetect -y 1 from the RPi.
The PIC is set to address 0x50
I can read values from the scratchpad by using the following RPi command
value=i2c.read_byte_data(0x50,0x01)
This reads the value of scratchpad location 0x01 and stores it in a variable called value.
the read only seems to work if I do the following code first
i2c.write_byte_data(0x50,0x00,0x00)
If i don't do this first then the value I read back is zero and not my count value.
I then tried to write a value to the scratchpad using the following RPi Command
i2c.write_byte_data(0x50,0x01,0x33)
This should write the value of 0x33 to location 0x01 in the scratchpad.
Here lies the problem.
It does not seem to write anything.
When I check the hi2cflag which should be set to 1 when a write event has taken place it is still set to 0.
Not sure i am doing this right and do not have any idea what I have done wrong.
Sorry if all this does not make any sense
Is there anyone out there that has had any experience of this.
any help would be useful
Many Thanks
Phil