David Bonet
New Member
Hi everyone,
I have one question about how to program master and slave device to work with i2c protocol.
My sistem use one master device and a certain number of slave devices. The objective of the slave devices is store a data and send it to the master when it demands. To store this data, I'm using a 24C08 memory connected with I2C protocol.
Then, my question is: Is there any problem if I connected the bus i2c from all boards and the memories? After test a little bit, comunication between picaxes was ok when I don't read the data in the memory. Maybe, if I setup one pic to work as a slave in I2C protocol, i can't use it as a master to read from memory. Can anybody told me if this is rigth?
This is a example about what I would like to do:
-- SLAVE --
hi2csetup i2cslave, %00000010
main:
i2cslave %10100000, i2cfast, i2cbyte
readi2c 0,(b1) 'Read in memory and save the value in b1
put 2, b1 'Put this value in scratchpad
goto main
-- MASTER --
hi2csetup i2cmaster, %00000010, i2cfast, i2cbyte
main:
hi2cin [%00000010],2,(b1)
debug b1
goto main
But in master device, I allways has 255 in b1 variable.
Could anybody help me, please?
Kind regards,
David
I have one question about how to program master and slave device to work with i2c protocol.
My sistem use one master device and a certain number of slave devices. The objective of the slave devices is store a data and send it to the master when it demands. To store this data, I'm using a 24C08 memory connected with I2C protocol.
Then, my question is: Is there any problem if I connected the bus i2c from all boards and the memories? After test a little bit, comunication between picaxes was ok when I don't read the data in the memory. Maybe, if I setup one pic to work as a slave in I2C protocol, i can't use it as a master to read from memory. Can anybody told me if this is rigth?
This is a example about what I would like to do:
-- SLAVE --
hi2csetup i2cslave, %00000010
main:
i2cslave %10100000, i2cfast, i2cbyte
readi2c 0,(b1) 'Read in memory and save the value in b1
put 2, b1 'Put this value in scratchpad
goto main
-- MASTER --
hi2csetup i2cmaster, %00000010, i2cfast, i2cbyte
main:
hi2cin [%00000010],2,(b1)
debug b1
goto main
But in master device, I allways has 255 in b1 variable.
Could anybody help me, please?
Kind regards,
David