i2c interface with LPC1114 and Arduino board

Please tell me how to interface NXP LPC1114 with Arduino board using I2C protocol.
I want to send some data through Arduno board on SCL and SDA using I2C protocol and Attaching this SCL and SDA cable to NXP board want to glow dimmer LED(PCA9532).
Please give me some idea and code.

Thanks

I know nothing of the LPC1114 but as it and the arduino are both microcontrollers which will be master/slave. The arduino wire library allows configuration as master or slave though I have never used slave mode myself.

ranjeetray:
Please tell me how to interface NXP LPC1114 with Arduino board using I2C protocol.
I want to send some data through Arduno board on SCL and SDA using I2C protocol and Attaching this SCL and SDA cable to NXP board want to glow dimmer LED(PCA9532).
Please give me some idea and code.

Thanks

It's incredibly unlikely that anyone here will simply write your code for you. Implementing I2C on the Arduino is easy, and you'll have to read the documentation for your LPC1114 to understand how it implements I2C.

Start here: http://www.nxp.com/documents/data_sheet/LPC111X.pdf

And happy reading!

[code][code][code][quote author=Verdris link=topic=115098.msg866399#msg866399 date=1342794960]
[quote author=ranjeetray link=topic=115098.msg866270#msg866270 date=1342785498]
Please tell me how to interface NXP LPC1114 with Arduino board using I2C protocol.
I want to send some data through Arduno board on SCL and SDA using I2C protocol and Attaching this SCL and SDA cable to NXP board want to glow dimmer LED(PCA9532).
Please give me some idea and code.


Thanks
[/quote]

It's incredibly unlikely that anyone here will simply write your code for you. Implementing I2C on the Arduino is easy, and you'll have to read the documentation for your LPC1114 to understand how it implements I2C.

Start here: http://www.nxp.com/documents/data_sheet/LPC111X.pdf

And happy reading!
[/quote]

Thanks for your kind reply.

[b]Following is the code for NXP PCA9532 dimmer LED which is working fine.[/b]
[code]
#include "driver_config.h"
#include "target_config.h"

#include "type.h"
#include "i2c.h"

extern volatile uint32_t I2CCount;
extern volatile uint8_t I2CMasterBuffer[BUFSIZE];
extern volatile uint8_t I2CSlaveBuffer[BUFSIZE];
extern volatile uint32_t I2CMasterState;
extern volatile uint32_t I2CReadLength, I2CWriteLength;

/*******************************************************************************
**   Main Function  main()
*******************************************************************************/
int main (void)
{
	  

  uint32_t i;
  int mm;

  if ( I2CInit( (uint32_t)I2CMASTER ) == FALSE )	/* initialize I2c */
  {
	while ( 1 );				/* Fatal error */
  }

  
  I2CMasterBuffer[0] = PCF8594_ADDR;
  I2CMasterBuffer[1] = 0x12;		/* address */
  I2CMasterBuffer[2] = 0x97;		/* Data0 */
  I2CMasterBuffer[3] = 0x80;		/* Data1 */
  I2CMasterBuffer[4] = 0x00;
  I2CMasterBuffer[5] = 0x40;
  I2CMasterBuffer[6] = 0x55;
  I2CMasterBuffer[7] = 0xFA;
  I2CMasterBuffer[8] = 0x00;
  I2CMasterBuffer[9] = 0x00;
 // I2CMasterBuffer[11] = 0x12;
  //I2CMasterBuffer[11] = 'P';
  I2CEngine();
  }
 
  for ( i = 0; i < 0x200000; i++ );	/* Delay after write */

  for ( i = 0; i < BUFSIZE; i++ )
  {
	I2CSlaveBuffer[i] = 0x00;
  }
  /* Write SLA(W), address, SLA(R), and read one byte back. */
  I2CWriteLength = 2;
  I2CReadLength = 4;
  I2CMasterBuffer[0] = PCF8594_ADDR;
  I2CMasterBuffer[1] = 0x00;		/* address */
  I2CMasterBuffer[2] = PCF8594_ADDR | RD_BIT;
  I2CEngine();

  return 0;
}

And for Arduino:-

#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}



void loop()
{

 Wire.beginTransmission(192);
 
 // Wire.beginTransmission(192); // transmit to device (0xc0)
                              // device address is specified in datasheet
  //Wire.write(byte(0x00));            // sends instruction byte  
  Wire.write(18);             // sends potentiometer value byte  
  Wire.endTransmission();
   Wire.write(151);
   Wire.endTransmission();
    Wire.write(128);
    Wire.endTransmission();
     Wire.write(0);
     Wire.endTransmission();
      Wire.write(64);
      Wire.endTransmission();
       Wire.write(85);
       Wire.endTransmission();
        Wire.write(250);
        Wire.endTransmission();
         Wire.write(0);
         Wire.endTransmission();
         Wire.write(0);
  
  Wire.endTransmission();     // stop transmitting
  }

So, I want to run the above Arduino code on the Arduino board and want to connect SCL , SDA and GND cable to the NXP board's pin respectively and after powering the NXP board I expect that dimmer light will glow on NXP board.

Is it possible.

Thanks
[/code][/code][/code][/code]

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

So, I want to run the above Arduino code on the Arduino board ...Is it possible.

Yes. You can run that code. If it compiles.

Thanks a lot for your kind reply and suggestions.
I tried code is running on Arduino board but PCA9532 dimmer LED is not glowing on NXP board.
What could be gone wrong with it.

Thnaks...

 Wire.beginTransmission(192);

  // Wire.beginTransmission(192); // transmit to device (0xc0)
  // device address is specified in datasheet
  //Wire.write(byte(0x00));            // sends instruction byte  
  Wire.write(18);             // sends potentiometer value byte  
  Wire.endTransmission();
  Wire.write(151);
  Wire.endTransmission();
  Wire.write(128);
  Wire.endTransmission();
  Wire.write(0);
  Wire.endTransmission();
  Wire.write(64);
  Wire.endTransmission();
  Wire.write(85);
  Wire.endTransmission();
  Wire.write(250);
  Wire.endTransmission();
  Wire.write(0);
  Wire.endTransmission();
  Wire.write(0);

  Wire.endTransmission();     // stop transmitting

That won't work. For every Wire.endTransmission you need a corresponding Wire.beginTransmission.

Why do you think it would work? You have lots of ends but only one begin. Better read this:

Thanks a lot for your reply.

I tried without so many Wire.endTransmission(); but still it is not working .
Please suggest me something on this.

Thanks....

ranjeetray:

[quote author=Nick Gammon link=topic=115098.msg867948#msg867948 date=1342919653]

 Wire.beginTransmission(192);

// Wire.beginTransmission(192); // transmit to device (0xc0)
 // device address is specified in datasheet
 //Wire.write(byte(0x00));            // sends instruction byte  
 Wire.write(18);             // sends potentiometer value byte  
 Wire.endTransmission();
 Wire.write(151);
 Wire.endTransmission();
 Wire.write(128);
 Wire.endTransmission();
 Wire.write(0);
 Wire.endTransmission();
 Wire.write(64);
 Wire.endTransmission();
 Wire.write(85);
 Wire.endTransmission();
 Wire.write(250);
 Wire.endTransmission();
 Wire.write(0);
 Wire.endTransmission();
 Wire.write(0);

Wire.endTransmission();     // stop transmitting




That won't work. For every Wire.endTransmission you need a corresponding Wire.beginTransmission.

Why do you think it would work? You have lots of ends but only one begin. Better read this:

http://www.gammon.com.au/i2c

Thanks a lot for your reply.

I tried without so many Wire.endTransmission(); but still it is not working .
Please suggest me something on this.

Thanks....
[/quote]

Hi...!!!

I tried like this also but on NXP LPC1114 with baseboard but PCA9532 is not glowing (LED Dimmer Light).
Even I checked it with 4.7Kohm pull up registers but still it is not working
Please suggest me something.

Code for Arduino:-

#include <Wire.h>

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}



void loop()
{



Wire.beginTransmission(192); // transmit to device (0xc0)
// device address is specified in datasheet
Wire.write(byte(0x00)); // sends instruction byte

Wire.write(151);

Wire.write(128);

Wire.write(0);

Wire.write(64);

Wire.write(85);

Wire.write(250);

Wire.write(0);

Wire.write(0);

Wire.endTransmission(); // stop transmitting
}

ranjeetray:
Even I checked it with 4.7Kohm pull up registers but still it is not working
Please suggest me something.

Not working or not compiling? I got:

sketch_jul23a.cpp: In function 'void loop()':
sketch_jul23a:22: error: call of overloaded 'write(int)' is ambiguous
/Applications/Arduino 1.0.app/Contents/Resources/Java/libraries/Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
/Applications/Arduino 1.0.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:49: note:                 size_t Print::write(const char*)
sketch_jul23a:30: error: call of overloaded 'write(int)' is ambiguous
/Applications/Arduino 1.0.app/Contents/Resources/Java/libraries/Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
/Applications/Arduino 1.0.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:49: note:                 size_t Print::write(const char*)
sketch_jul23a:32: error: call of overloaded 'write(int)' is ambiguous
/Applications/Arduino 1.0.app/Contents/Resources/Java/libraries/Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
/Applications/Arduino 1.0.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:49: note:                 size_t Print::write(const char*)
sketch_jul23a.cpp: At global scope:
sketch_jul23a:38: error: expected declaration before '}' token

Hi..!!!

In my Arduino board it is compiling as well as loading also, even data is available on oscilloscope which I am not able to understand but my NXP PCA9532 is not glowing at all.

Kindly suggest me, what to do now.

Thanks.....

In my Arduino board it is compiling as well as loading also

Using what version of the IDE? What Arduino?

PaulS:

In my Arduino board it is compiling as well as loading also

Using what version of the IDE? What Arduino?

Hi....!!!

IDE :arduino-1.0.1
H/W:Arduino Uno

Thanks.....

Maybe the problem is with the software you use/have written for the NXP LPC1114

That code you posted does not compile on 1.0.1, for me. There is an extra } at the end. It fails with the same messages Nick posted on 1.0.

PaulS:
That code you posted does not compile on 1.0.1, for me. There is an extra } at the end. It fails with the same messages Nick posted on 1.0.

Sorry, an extra } is there, please remove it and then try.

Thanks....

please remove it and then try.

PM me, and I'll send you an address where you can send me your Arduino and LPC1114.

PaulS:

please remove it and then try.

PM me, and I'll send you an address where you can send me your Arduino and LPC1114.

Hahahaha...
Please give me the address...!!!

Thanks.... :grin:

Hi..!!!

I tried like this also but still NXP PCA9532 is not glowing, I have provided pull up register of 4.7Kohm.

#include <Wire.h>
#include <Serial.h>

void setup()
{
 // Wire.begin(0xc0); // join i2c bus (address optional for master)
  Wire.begin();
}

void loop()
{
byte array[10] = {0x12,0x97,0x80,0x00,0x40,0x55,0xFA,0x00,0x00};
                
  Wire.beginTransmission(0xc0);
  Wire.write(array,10);             
  Wire.endTransmission();
}

Where I am wrong in sending the data , Please guide me.

Thanks......

Now that you've posted code that actually compiles, I notice this:

Wire.beginTransmission(0xc0);

I2C addresses are 0 (for broadcast) to 119. That is 0x00 to 0x77.

Your address of 0xC0 is outside that range.


PaulS:
PM me, and I'll send you an address where you can send me your Arduino and LPC1114.

ranjeetray:
Please give me the address...!!!

@PaulS: please let us know the results of your investigations. I'm sure we're all ears. :slight_smile: