I2c

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

I2c

3,614 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sat Apr 23 15:14:53 MST 2011
Hi friends ,ı have never tried this I2C...

and ı want to use arm as a slave and but ı dont know how to use ...can u help me?
0 Kudos
Reply
15 Replies

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Tue Apr 26 07:43:51 MST 2011
Rob its done ,thank you for your help...
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Apr 24 07:49:51 MST 2011

Quote: Zero
As posted in #6 there is a sample for I2Cslave with LPC1769 :). Is there a special reason why you don't try to start with it :mad: or are you just kidding us?



Aaarrghhh....

There are two different zips with sample code for the 17xx series.
One called "examples projects" - waste of time downloading these ...
The other is the MBC1700 sample code bundle that one contains the i2c example (both slave and master) but if the slave project is as good as the master ...
I've been adapting and testing the master driver about 8 months ago and the examples still contain an old - not properly functioning driver with errors in it :mad:

One of the first lines in the lpc17xx I2C slave test program reads:
#include "LPC17xx.h"            /* LPC11xx Peripheral Registers */


I've also downloaded and tested the FreeRTOS example, somehow there is no Release configuration, only a Debug and somehow if you mess up the code the SimpleDemo will tell you there is a problem with some Blinky file.
On top of this there are still bugs in the user manual (I still have not found where I2CPCLK comes from) :eek:

really... I have to [I]do[/I] stuff to create a project without a release configuration and that blinky stuff makes me think that the project was just converted from blinky instead of just creating a new (clean) project.
It's a good thing I am an experienced programmer and I am not depending on these examples to learn programming on these devices ...
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Apr 24 06:27:08 MST 2011
As posted in #6 there is a sample for I2Cslave with LPC1769 :). Is there a special reason why you don't try to start with it :mad: or are you just kidding us?
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Apr 24 05:52:42 MST 2011
Cesim,

It makes me sad - not mad ...
Even after 30 years of embedded programming it still feels like having to start all over again as soon as I get to a new programming environment or target. I discovered there is no shortcut; I have to read to manuals, try out stuff and fail doing so in order to understand what is going on.

Things only become easier after figuring out yourself what is going on. When I started with the LPCXpresso about two years ago I found a lot of problems and at that time there were even still a few bugs in the manuals. I updated the I2C driver (master mode only though) from NXP because I needed it and decided to provide it back to the community because there were more people looking for a proper driver.

Sometimes things are easy but only if the proper information is received.
In another topic you wrote:

Quote: cesimkaol
../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.)


You are using an lpc17xx so for one you have to include the correct LPC17xx.h file instead. And the 17xx has (as far as I know) multiple I2C interfaces so you may have to change the defines for this.
Compile the code, look at the errors and try to solve the errors.

I could not find the I2C examples in the lpc17xx examples either (too bad that NXP did not provide all the sample code from the lpc11xx and 13xx for the 17xx also). Most of the peripherals from the lpc13xx are available in the 17xx also so you can just adapt the code from the lpc13xx examples for your scenario.

When changing the I2C examples, please also take a look at the Interrupt Controller and the name for the interrupt handler - I don't know but there could be different interrupt handlers for both I2C controllers.

Regards,

Rob
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sun Apr 24 05:00:06 MST 2011
I know rob it makes you mad....I read it whole part of it...try to create project many times...:S but ı still can not see where is the problem...ok ...ı will do it by myself..thnx...
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Apr 24 04:53:09 MST 2011

Quote: cesimkaol
when ı debug it,following errors occurs...I added necessary libraries from CIMSIS ...but ı cant solve...

"../src/i2cslave.c"
../src/i2cslave.c: In function 'I2C_IRQHandler':
../src/i2cslave.c:53: error: 'LPC_I2C' undeclared (first use in this function)



These are compiler errors. You are not even getting within a mile from your target board at this time.
Please make sure you have set up your LPCXpresso project correctly: select the proper MCU settings, directories and other stuff. The quickstart manual delivered with the software, the lpc17xx user manual and the FAQ at the CodeRed website should get you up&running with this.
Even if someone would hand you a complete working project I doubt that, without consulting any of the available documentation, you would be able to create a working project.
Sorry but I don't think we could explain you everything you need to know. A lot of this stuff (like how to assign a slave address) can be found in the manuals already.

Ok, just this once: section 19.6.3 "Slave receiver mode" in the lpx17xx user manual tells you "To initialize
the slave receiver mode, write any of the Slave Address registers (I2ADR0-3)".
Now read the rest of chapter 19 and especially take a look at "19.8.7 I2C Slave Address registers"

Rob
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sun Apr 24 03:34:36 MST 2011
Do you have any working project...can u please share with me...you can create zip file for example project... :)...it will be appreciated...
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sun Apr 24 03:32:59 MST 2011
when ı debug it,following errors occurs...I added necessary libraries from CIMSIS ...but ı cant solve...

"../src/i2cslave.c"
../src/i2cslave.c: In function 'I2C_IRQHandler':
../src/i2cslave.c:53: error: 'LPC_I2C' undeclared (first use in this function)
../src/i2cslave.c:53: error: (Each undeclared identifier is reported only once
../src/i2cslave.c:53: error: for each function it appears in.)
../src/i2cslave.c: In function 'I2CSlaveInit':
../src/i2cslave.c:141: error: 'LPC_SYSCON' undeclared (first use in this function)
../src/i2cslave.c:146: error: 'LPC_IOCON' undeclared (first use in this function)
../src/i2cslave.c:152: error: 'LPC_I2C' undeclared (first use in this function)
../src/i2cslave.c:169: error: 'I2C_IRQn' undeclared (first use in this function)
make: *** [src/i2cslave.o] Error 1
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by martinho on Sun Apr 24 03:30:18 MST 2011

Quote: cesimkaol


but I dont have A1,A2,A3 pins so how can ı assign slave and master address..?




You have to set the I2C Address registers
LPC_I2Cx->I2ADR0 to LPC_I2Cx->I2ADR3
and the relative Mask registers
LPC_I2Cx->I2MASK0 to LPC_I2Cx->I2MASK3
to define the Address where you need to communicate with your Master.

See I2C description in LPC17xx User-manual (Chapter 19 page 436)

I2C Drivers are complicated because I2C is complicated;)

Martin
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sun Apr 24 02:19:07 MST 2011
My task is ,originate  connection between MSP430 and my lpcxpreso via using I2C...

but I dont have A1,A2,A3 pins so how can ı assign slave and master address..?

when ı examine code...ı dont know how to assign...
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 23 16:59:14 MST 2011
What's wrong with i2c master / slave examples in:

MCB1700 Sample Code Bundle for LPC1769 Peripherals using LPCXpresso V2.00 (Jan 10, 2011)?

See:

http://ics.nxp.com/support/lpcxpresso/#Examples
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sat Apr 23 16:46:08 MST 2011
Zero I just want to have sample code for 1769...easy one...
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 23 16:13:00 MST 2011
Sorry, I'm no clairvoyant. So I don't know what you want to do and what you have tried before :confused:
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cesimkaol on Sat Apr 23 15:55:26 MST 2011
zero ı treid it many times...it does not work :(

And I want to notice about mcu ,I have 1769....

Please work with me and ı wanna solve this problem...thnx
0 Kudos
Reply

3,562 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 23 15:28:00 MST 2011
In your example folder within example.lpc13xx.new.zip there is a sample :) called 'i2cslave' ...
0 Kudos
Reply