Multimaster i2C with a LPC1343

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multimaster i2C with a LPC1343

1,429 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Tue Feb 01 08:13:25 MST 2011
Hi,

In a project I am working on, I have just found that multimaster operation is needed.

On one end there is a PIC already set up as a master (over which I have no control), on my end there is the LPC1343, which up till now, I have been using as a master to control various slave devices, eg ADCs, DAC.

Is there any way to get the LPC1343 into a safe master/master configuration? In the UM10375 manual there is a hint ([FONT=Arial][SIZE=3][COLOR=#005042][FONT=Arial][SIZE=3][COLOR=#005042][FONT=Arial][SIZE=3][COLOR=#005042][SIZE=2][COLOR=black][B]12.11.6.1 Simultaneous Repeated START conditions from two masters)[/B].[/COLOR][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
[FONT=Arial][SIZE=2][/SIZE][/FONT]
[FONT=Arial][SIZE=2][FONT=Times New Roman][SIZE=3]JohnR[/SIZE][/FONT].[/SIZE][/FONT]
[FONT=Arial][SIZE=3][COLOR=#005042][FONT=Arial][SIZE=3][COLOR=#005042][FONT=Arial][SIZE=3][COLOR=#005042][SIZE=2][COLOR=#000000][/COLOR][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
[FONT=Arial][SIZE=3][COLOR=#005042][FONT=Arial][SIZE=3][COLOR=#005042][FONT=Arial][SIZE=3][COLOR=#005042][SIZE=2][COLOR=#000000][/COLOR][/SIZE]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
0 Kudos
Reply
5 Replies

1,382 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Tue Apr 26 07:43:14 MST 2011
I did not give my attention that headers...sorry about it ...ı fixed the problems...Thank you for your interest....I thought that examples are for 1769...

danke again...
0 Kudos
Reply

1,382 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Apr 24 06:29:52 MST 2011
You can't use LPC111x samples with LPC1769, therefore compiler complains about register names :mad:
0 Kudos
Reply

1,382 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sun Apr 24 04:47:50 MST 2011
its not working... still get an error....

../src/i2c.c:16:58: error: LPC11xx.h: No such file or directory
../src/i2c.c: In function 'I2C_IRQHandler':
../src/i2c.c:46: error: 'LPC_I2C' undeclared (first use in this function)
../src/i2c.c:46: error: (Each undeclared identifier is reported only once
../src/i2c.c:46: error: for each function it appears in.)
../src/i2c.c: In function 'I2CStart':
../src/i2c.c:233: error: 'LPC_I2C' undeclared (first use in this function)
../src/i2c.c: In function 'I2CStop':
../src/i2c.c:256: error: 'LPC_I2C' undeclared (first use in this function)
../src/i2c.c: In function 'I2CInit':
../src/i2c.c:279: error: 'LPC_SYSCON' undeclared (first use in this function)
../src/i2c.c:281: error: 'LPC_IOCON' undeclared (first use in this function)
../src/i2c.c:287: error: 'LPC_I2C' undeclared (first use in this function)
../src/i2c.c:306: warning: implicit declaration of function 'NVIC_EnableIRQ'
../src/i2c.c:306: error: 'I2C_IRQn' undeclared (first use in this function)
make: *** [src/i2c.o] Error 1
0 Kudos
Reply

1,382 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Apr 24 04:15:31 MST 2011
The I2C interface of the lpc11xx and 13xx processors has build in support for muti master mode.

A start condition will only be generated by the I2C controller when the I2C is free: only if both the SDA and SCL lines are high, the start condition will be generated: first SDA is taken low and after this SCL.

Suppose two masters perform this check at the exact same time, in that case they will both take control and start sending clock pulses and the slave address. The master detecting that one of the lines SDA or SCL is low when it is not driving the line [B]must[/B] detect that another device (i.e. another master) is driving the I2C bus.

The lpc13xx will detect this and release the bus, returning an error code to the program of course this must be supported by the i2c driver being used.
Please note that the driver provided by NXP in the sample code is [B]not handling arbitration loss!![/B] If you are looking for a driver, please take a look at posting #11 in the "I2C on LPC1343"  thread or at my website. There you will find i2c_driver_v1.10.zip with a changed driver that does handle the arbitration loss. That driver will also return an error code to the calling program (something the sample code in the NXP examples does not do).
Too bad that NXP did not take this into account (if they ask me, they may gladly use my changes - it's all based on the original NXP code :D)

Note that your PIC or MSP430 must also support multi master mode.
Next to the hardware being able to handle arbitration loss, you must also take case of this in your own code: if you try to read or write an I2C device and it fails you have to either wait and try again or flag this as an error and do something else.

The [I]simultaneous repeated start condition from two masters[/I] is a special case.  Here we are in the middle of a read transaction; first we transmit a START, Slave address + write condition and something like a device address (e.g. an address in an EEPROM). After this we send a STOP, START, Slave address + read condition and then we start reading data.
Right after sending the first STOP, another master may decide to take the bus so we may lose the read part of our write/read transaction.
The i2c driver reports one return value (I2CSTATE_ARB_LOSS) independent from the fact if arbitration loss was in the first or second part of the transaction sequence so for your program this should not be that much of a difference.

Please note that although the driver should work in multi master mode (since this is handled in the I2C hardware) I have not tested this. I could test this and provide more detailed documentation and test report but that is a commercial service ...

Rob
0 Kudos
Reply

1,382 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sun Apr 24 02:23:24 MST 2011
I try to implement same scenario...I  use MSP430 instead of PIC...But I still can not solve problem...
0 Kudos
Reply