Author Topic: I2C in slave mode  (Read 12221 times)

Offline svl

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
I2C in slave mode
« on: October 14, 2010, 02:39:25 PM »
Hi Mark

We have been using the uTasker for over 2 years and are very pleased with the performance and functions ;-).
In our upcoming products we plan to make a bus system that uses I2C. I can see that there are support for I2C master, but can’t see that the I2C slave are implemented.
Is the I2C slave hidden some ware in uTasker that I cannot see?

Regards Steen

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: I2C in slave mode
« Reply #1 on: October 14, 2010, 10:16:16 PM »
Hi Steen

There is really no support for I2C slave in the project.

There are 2 reasons for this:
1) I2C slave is in fact used very infrequently (I2C master is used a lot but I don't actually know of a user's project that makes use of I2C slave - although they may have added it themselves without announcing this in any way).
2) Multi-master I2C can be complicated (especially due to loss of ownership, etc.). Since there was so little (almost zero) interest in this I decided against a development.
This may however be based on non-typical experience which biased the decision. The fact is that I was involved with quite a large a project with multi-master I2C which was using the bus as a communication bus between the masters as well as more typical I2C peripheral control. The controllers actually used ASICs to combine this function together with others and the implementation was possibly not perfect. In any case, the result was that the communication was a cause of problems in the system and required a long time of debugging, proving where it was going wrong and finding workarounds (when no more ASIC improvements were possible) - possibly EMC based glitches also caused the bus to hang in certain states.
Although maybe not typical experience, it has made me very wary of such solutions. In fact I never understood the choice of I2C in that case since there are enough standard and simpler solutions available to achieve the same.

This doesn't help you with your project but it gives background information as to the main reasons why there is no slave driver (at the moment).

Regards

Mark

Offline svl

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: I2C in slave mode
« Reply #2 on: October 15, 2010, 06:48:38 AM »
Hi Mark

Too bad, that the Slave was not there ;-)

The reason for us to select the I2C as the physical buss interface is infact:
1) On the Freescale M5225X, we are all out of alternative hardware connections. We already use the LAN, 3xRS232, SPI + a SW SPI, USB. So the I2C was the only thing left, which requires a minimum of extra hardware.
2) Creating additional expansion board is easy simply using a cheap I2C -> IO chip.

To complete the circle we then had the idée that the M5225X should be able to change operation mode from master to slave module, with simple software configuration.

I guess that this means that there only is the hard way to solve this?

Regards

Steen

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: I2C in slave mode
« Reply #3 on: October 15, 2010, 11:32:57 AM »
Hi Steen,

We use I2C to access (in Master mode) quite a lot, and generally it has proved a good interface. We primarily use the Luminary Micro LM3Sxxxx range of chips.

We have found that under harsh conditions (external EMI) you can get into "lock-up" conditions on the bus where the SDA line is being held low by the external slave device (Clock extension). Currently we have switch the GPIO lines assigned to the I2C to GPIO mode and manually clock the SCL line to get out of this mode. This may be a limitation with the LM3S chips.

Of course EMI might not be an issue for you.

Have you thought of connecting an external UART(s) via the SPI or I2C interfaces, I understand this works well in uTasker. In fact we are working on a project where a philips SC16IS750 uart will be interfaced with our chip via SPI. These chips are quite good as you can get single and dual versions. Maxim also do a slightly different version that does not need an external baudrate crystal.

I'm a bit cunfused by your point (2) if you want to connect an external IO expansion board then you need to run uTasker in I2C master mode, which it already supports.

Regards

Martin
 

Offline svl

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: I2C in slave mode
« Reply #4 on: October 20, 2010, 12:30:48 PM »
Hi Martin

Thanks for your input.

My last post was just for explaining why we have selected I2C as our buss and not one of the other communications ports available in the M5225X ;-).

The reason for having the M5225X to run as a slave unit are that in many cases there will be 2 identical (HW) units on will be configured as master and one as slave..

We are planning to use the SC16IS752 from NXP it has a dual UART and 8 SW controlled I/O.
When you say that is works well with uTasker do you mean that a driver already exist(Always on the look for things that saves me time ;-)) or that it is possible to integrate it in the uTasker?

Regards

Steen

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: I2C in slave mode
« Reply #5 on: October 20, 2010, 01:44:25 PM »
Hi Steen,

Yes we have been working with Mark to provide a SC16IS7xx driver for the LM3Sxxxx chips, its pretty generic. So should be portable to the M5225X. We use the SPI interface to communicate to the SC16IS760 chip in our case (we only needed on extra UART). I'm running Modbus RTU at 115200 baud through a SC16IS760, I'm also using the nice auto gating feature of the SC16IS760 to turn the RS485 half duplex driver on and off.

Best to talk to Mark about porting the driver to the M5225X, should be just the SPI routines I would think. May require more work if you wanted to interface to this chip via I2C.

Cheers

Martin

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: I2C in slave mode
« Reply #6 on: October 20, 2010, 01:47:32 PM »
Hi Steen

Presently there are SC16IS752 drivers which operate with the SAM7 and Luminary projects. To be adapted to other projects the initialisation (connection, clock, IRQ used etc.) needs to be modified. Also the low level register read/write routines have to be adapted for the particular processor. It is not a huge amount of work but does take at least a day with testing.

The SPI interface is used since it is much faster than the I2C interface. I am wondering whether you are planning on using the SC16IS752  in I2C mode?? [that hasn't been done before]

Regards

Mark

Offline svl

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: I2C in slave mode
« Reply #7 on: October 21, 2010, 06:37:04 AM »
Hi Mark

I am planning to use the SC16IS752 in the I2C interface.

The plan is to connect up to 3 SC16IS752 on the I2C interface.
We are planning to poll the SC16IS752 units and if there are data from the UART the collect them.
In our system there is a low amount of traffic so data getting lost are not a big concern at the moment.

And as the ideer was then that in some cases the SC16IS752 was replaced with the M5225X in a I2C slave configuration.

If possible I woudt like to see the driver you have made for the Luminary chip? I expect that i can resue a lot of the setup code for the SC16IS752 chip.
 
Thanks

Regards

Steen

Offline Xylifrost

  • Newbie
  • *
  • Posts: 2
  • ground control
    • View Profile
    • Personal hovercraft for sale in the UK
I2C in slave mode
« Reply #8 on: January 07, 2011, 08:54:50 PM »
Does the 430EX manual mode not work when also in slave mode? If I put the flash in manual mode, and then flip the slave switch on, it goes to ETTL and then the mode button has no effect. I assume manual isnt possible with slave on, but just want to be sure my flash isnt broken.
To see affordable luxury cars rental deals in Miami visit my personal service.