5

Only the X2 parts of the PICAXE family support I2C slave compatibility, but I need to have an 08M2 to act as an I2C slave on a board that I have. Unfortunately I don't have the option of changing micro-controller or making a new board.

I've been reading up on how the I2C protocol works and have found some code which may help, but haven't got any further. Has anyone done a similar thing before? If anyone has some example code which works which I can go from it would be fantastic.

m.Alin
  • 10,638
  • 19
  • 62
  • 89
P78
  • 51
  • 2
  • 2
    The hard thing about I2C is that it's open collector \ open drain, so instead of working with 1s and 0s only, you have also to continuously switch between input and output; not that it's impossible, but requires some work on it. – clabacchio Feb 04 '12 at 19:13
  • Not really. Switching between input and output can be done by writing to the direction register (TRIS) instead of the port data register. No, the hard part about i2c slaves is that you must not miss the messages directed at you, and without a slave peripheral you don't have interrupts or even a receiving register to help you. So you spend all your processor time watching the bits come in. – gbarry Oct 14 '12 at 02:25

2 Answers2

1

With one master node and multiple PICAXE-08M2 I2C slaves, "diode-mixing" approach may be the easiest/cheapest solution or substitute an X1 chip.

  • single pull-up resistor for the comm. line Ea
  • each slave connects data via anode of Schottky diode & cathode to PICaxe
  • PICaxe input is connected to the comm line via a 10K resistor
  • Use simple SEROUT and SERIN operation with qualifiers to address each node
  • many others have implemented such a Serial protocol, so don't reinvent the wheel.

Grounding, shielding, impedance control and low capacitance wiring is essential. eg 7pF/ft

can you say let's have a party line? Consult with those who have done it, after you try it. enter image description here

Tony Stewart EE75
  • 1
  • 3
  • 54
  • 182
0

While I'm sure it's possible, its not something that I'd want to take on. If it were my design challenge to meet, I'd be looking very hard for an SPI to I2C converter, because SPI is just so much easier to bit bang. First efforts to search for this point me to http://www.silabs.com/products/interface/spitoi2c/Pages/default.aspx and http://ics.nxp.com/products/bridges/spi.slave.i2c.master.gpio/. I'm not quite sure this is right, but I'd say its worth running it down.

Scott Seidman
  • 29,274
  • 4
  • 44
  • 109