1769 -I2C doesn't work

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

1769 -I2C doesn't work

4,680 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Thu Jun 28 06:44:03 MST 2012
I am trying make work the i2c of 1769.

I carry the example . But he doesn`t work.

I am using the i2c1. Pines PIO0.0 and  PIO0.1 of micro.
The resistor of pull-up are OK.

What can are wrong?
0 Kudos
Reply
17 Replies

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by yakin on Sat Jul 06 07:42:38 MST 2013
This is my first contribution and I hope it will not be the last, at the beginning I had dificulties to read data from a PCF8574, data are collected on I2CSlaveBuffer [PORT_USED] [0] be transmitted on UART0, This is how I do it:
int main (void)
{
   uint32_t i;

SystemClockUpdate () / * updates the SystemFrequency variable * /
UART0Count = 1;
UARTInit (0, 38400) / * baud rate setting * /
 
I2C2Init () / * initialize I2c2 * /
I2CReadLength [PORT_USED] = 1;
I2CWriteLength [PORT_USED] = 2;
I2CMasterBuffer [PORT_USED] [0] = PCF8574_ADDR;
I2CMasterBuffer [PORT_USED] [1] = 0xFF;
I2CMasterBuffer [PORT_USED] [2] = PCF8574_ADDR | RD_BIT;

while (1) {

I2CEngine (PORT_USED);
UART0Buffer [0] = I2CSlaveBuffer [PORT_USED] [0];

LPC_UART0-> IER = IER_THRE | IER_RLS / * Disable RBR * /
UARTSend (0, (uint8_t *) UART0Buffer, UART0Count);
LPC_UART0-> IER = IER_THRE | IER_RLS | IER_RBR / * Re-enable RBR

}
}
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Tue Jul 03 05:15:11 MST 2012

Quote: Rob65
Does this mean that it is working now or that you think the define is OK?

Please just provide the source for the define and let us decide weather it's OK or not.

Rob



Now, is working one parte of my program. I found errors in  the file i2c.c
The program just send the first datium, the address of slave.. After, he doesn't worked..

In fuction  [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]I2C1Init
[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]
[LEFT]LPC_SC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PCONP[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (1 << 19);
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* set PIO0.19 and PIO0.20 to I2C1 SDA and SCL */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* function to 11 on both SDA and SCL. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->PINSEL1 &= ~((0x3<<6)|(0x3<<8));
LPC_PINCON->PINSEL1 |= ((0x3<<6)|(0x3<<8));
LPC_PINCON->PINMODE1 &= ~((0x3<<6)|(0x3<<8));
LPC_PINCON->PINMODE1 |= ((0x2<<6)|(0x2<<8)); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* No pull-up no pull-down */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->PINMODE_OD0 |= ((0x1<<19)|(0x1<<20));[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* set PIO0.0 and PIO0.1 to I2C1 SDA and SCL */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* function to 11 on both SDA and SCL. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINSEL0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~((0x3<<0)|(0x3<<2));
LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINSEL0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= ((0x3<<0)|(0x3<<2));
LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINMODE0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~((0x3<<0)|(0x3<<2));
LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINMODE0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= ((0x2<<0)|(0x2<<2)); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* No pull-up no pull-down */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINMODE_OD0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= ((0x01<<0)|(0x1<<1)); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Open drain */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/*--- Clear flags ---*/[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CONCLR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC; 

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/*--- Reset registers ---*/[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SCLL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2SCLL_SCLL;
LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SCLH[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2SCLH_SCLH;

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Install interrupt handler */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]NVIC_EnableIRQ([/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]I2C1_IRQn[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/LEFT]
LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CONSET[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2CONSET_I2EN;
[/SIZE][SIZE=2][LEFT]LPC_SC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PCONP[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (1 << 19);
[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* set PIO0.19 and PIO0.20 to I2C1 SDA and SCL */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* function to 11 on both SDA and SCL. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->PINSEL1 &= ~((0x3<<6)|(0x3<<8));
LPC_PINCON->PINSEL1 |= ((0x3<<6)|(0x3<<8));
LPC_PINCON->PINMODE1 &= ~((0x3<<6)|(0x3<<8));
LPC_PINCON->PINMODE1 |= ((0x2<<6)|(0x2<<8)); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* No pull-up no pull-down */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->PINMODE_OD0 |= ((0x1<<19)|(0x1<<20));[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* set PIO0.0 and PIO0.1 to I2C1 SDA and SCL */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* function to 11 on both SDA and SCL. */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINSEL0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~((0x3<<0)|(0x3<<2));
LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINSEL0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= ((0x3<<0)|(0x3<<2));
LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINMODE0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~((0x3<<0)|(0x3<<2));
LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINMODE0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= ((0x2<<0)|(0x2<<2)); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* No pull-up no pull-down */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_PINCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PINMODE_OD0[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= ((0x01<<0)|(0x1<<1)); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Open drain */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#endif[/LEFT]
[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/*--- Clear flags ---*/[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CONCLR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC; 

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/*--- Reset registers ---*/[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SCLL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2SCLL_SCLL;
LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SCLH[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2SCLH_SCLH;

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Install interrupt handler */[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]NVIC_EnableIRQ([/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]I2C1_IRQn[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/LEFT]
LPC_I2C1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CONSET[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = I2CONSET_I2EN;
[/SIZE]


The if0 and if1 was inverted. Now, I think there are more errors.
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Mon Jul 02 12:41:42 MST 2012

Quote: bruno
It is OK.


Does this mean that it is working now or that you think the define is OK?

Please just provide the source for the define and let us decide weather it's OK or not.

Rob
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Mon Jul 02 04:51:07 MST 2012
It is OK.

Bruno Braga
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Sun Jul 01 23:51:22 MST 2012
[SIZE=2]I would like to see the define for "PCF8594_ADDR". Just to be sure.[/SIZE]
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Fri Jun 29 07:31:45 MST 2012

Quote: Polux rsv
Is everything initialized in I2C1Init(); ?
-I2C1 peripheral activated ?
-Clock source, dividers, speed correctly setup for your device ?
-IO pins configured as I2C1 port ?

Angelo


  Hello

- Yes.
- Too, doesn't wrong.
- Yes..


Thanks Bruno Braga
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Fri Jun 29 07:25:23 MST 2012
For there are not doubts here my code complete:
[LEFT]#include[SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]<cr_section_macros.h>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2a00ff][/LEFT]

[/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#include
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]<NXP/crp.h>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2a00ff]
[/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Variable to store CRP value in. Will be placed automatically[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]// by the linker when "Enable Code Read Protect" selected.[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]// See crp.h header for more information[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]__CRP [/LEFT]
[/LEFT]
[/SIZE][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]const[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]unsigned[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] CRP_WORD = CRP_NO_CRP ;[/SIZE]
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#include[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"lpc17xx.h"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2a00ff]
[LEFT][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#include[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"type.h"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2a00ff]
[LEFT][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#include[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"i2c.h"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2a00ff]
[/COLOR][/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extern[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]volatile[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] I2CMasterBuffer[I2C_PORT_NUM][BUFSIZE];[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extern[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]volatile[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint8_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] I2CSlaveBuffer[I2C_PORT_NUM][BUFSIZE];[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extern[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]volatile[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] I2CReadLength[I2C_PORT_NUM];[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extern[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]volatile[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] I2CWriteLength[I2C_PORT_NUM];[/SIZE]
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#define[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][SIZE=2]PORT_USED 1[/SIZE]
 
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/*******************************************************************************[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]** Main Function main()[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]*******************************************************************************/[/COLOR][/SIZE]
[/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/LEFT]
[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][/B][LEFT][SIZE=2][B]main[/B] ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2])[/SIZE]
[LEFT][SIZE=2]{[/SIZE][/LEFT]
 
[LEFT][SIZE=2] [/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* SystemClockUpdate() updates the SystemFrequency variable */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2]SystemClockUpdate();[/SIZE][/LEFT]
 
[LEFT][SIZE=2] [/SIZE]
[SIZE=2]I2C1Init( ); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* initialize I2c1 */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][/LEFT]
[/COLOR][/SIZE]
[LEFT][SIZE=2] [/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* In order to start the I2CEngine, the all the parameters [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[SIZE=2][COLOR=#3f7f5f]must be set in advance, including I2CWriteLength, I2CReadLength,[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CCmd, and the I2cMasterBuffer which contains the stream[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]command/data to the I2c slave device. [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f](1) If it's a I2C write only, the number of bytes to be written is [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CWriteLength, I2CReadLength is zero, the content will be filled [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]in the I2CMasterBuffer. [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f](2) If it's a I2C read only, the number of bytes to be read is [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CReadLength, I2CWriteLength is 0, the read value will be filled [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]in the I2CMasterBuffer. [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f](3) If it's a I2C Write/Read with repeated start, specify the [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CWriteLength, fill the content of bytes to be written in [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer, specify the I2CReadLength, after the repeated [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]start and the device address with RD bit set, the content of the [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]reading will be filled in I2CMasterBuffer index at [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[I2CWriteLength+2]. [/COLOR][/SIZE][/LEFT]
 
[LEFT][SIZE=2][COLOR=#3f7f5f]e.g. Start, DevAddr(W), WRByte1...WRByteN, Repeated-Start, DevAddr(R), [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]RDByte1...RDByteN Stop. The content of the reading will be filled [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]after (I2CWriteLength + two [U]devaddr[/U]) bytes. */[/COLOR][/SIZE][/LEFT]
[/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Write SLA(W), address and one data byte */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2]I2CWriteLength[PORT_USED] = 3;[/SIZE]
[SIZE=2]I2CReadLength[PORT_USED] = 0;[/SIZE]
[SIZE=2]I2CMasterBuffer[PORT_USED][0] = PCF8594_ADDR;[/SIZE]
[SIZE=2]I2CMasterBuffer[PORT_USED][1] = 0x00; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* address */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][SIZE=2]I2CMasterBuffer[PORT_USED][2] = 0x55; [/LEFT]
[/LEFT]
[/SIZE][LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Data0 */[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[LEFT][/COLOR][/SIZE][SIZE=2]I2CEngine( PORT_USED );[/SIZE][/LEFT]
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] 0;[/SIZE][/LEFT]
[SIZE=2]}[/SIZE]


All this is stranger, because the code is very simple.
[/LEFT]
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Fri Jun 29 05:03:28 MST 2012

Quote: Serge
Bruno,

[LIST=1]
[*]Export your project and post your code here.
[*]Are you using the lpcxpresso 1769 board or a custom board. In case of a custom board we want to see at least the I2C part of the schematic.
[*]What is the hardware you are trying to get working, the chip-number would be great.
[*]Which version of the IDE do you use?
[/LIST]Without knowing the above we won't be able to help.




Hello,

The code complete is the example, I just change the address of slave. Because I am using the PCF2129 ( address of slave him is A2). Of couse, the data with will record at PCF2129.
I am using LPCXpresso v4.1.5_219 version.
Too, I am using 1769 board  called LCXpresso LPC1769 REV B.
The I2C ative is I2C 1, of the  Pines PIO0.0 and PIO0.1 .
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Fri Jun 29 04:53:07 MST 2012

Quote: atomicdog
What doesn't work?
Have you used the debugger to try and find the problem?



Hello,
He just doesn't work. The code is sure. When I make debugger no errors.

Thanks,
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Fri Jun 29 02:51:41 MST 2012
Guys,

please ....
Bruno lives in Brazil so he is still asleep right now.
Could we at least give him a chance to react before flooding the forum with a lot if these (obvious) questions.

Rob
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Fri Jun 29 02:32:27 MST 2012
Is everything initialized in I2C1Init();  ?
-I2C1 peripheral activated ?
-Clock source, dividers, speed correctly setup for your device ?
-IO pins configured as I2C1 port ?

Angelo
[SIZE=2][/SIZE]
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by researchinnovation on Fri Jun 29 00:20:19 MST 2012

Quote: bruno
I am trying make work the i2c of 1769.

I carry the example . But he doesn`t work.

I am using the i2c1. Pines PIO0.0 and  PIO0.1 of micro.
The resistor of pull-up are OK.

What can are wrong?




Hi..!!

What is the exact error, you are getting on console. Can you share it with us.



Thanks & Regards......:)
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Thu Jun 28 23:59:46 MST 2012
Bruno,

[LIST=1]
[*]Export your project and post your code here.
[*]Are you using the lpcxpresso 1769 board or a custom board. In case of a custom board we want to see at least the I2C part of the schematic.
[*]What is the hardware you are trying to get working, the chip-number would be great.
[*]Which version of the IDE do you use?
[/LIST]Without knowing the above we won't be able to help.
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by creafyumi on Thu Jun 28 18:03:51 MST 2012
No useful information provided. It will be very hard for other forum members to help.
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by atomicdog on Thu Jun 28 12:41:14 MST 2012
What doesn't work?
Have you used the debugger to try and find the problem?
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Thu Jun 28 09:32:26 MST 2012
Someone for help me??
0 Kudos
Reply

4,619 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Thu Jun 28 06:47:23 MST 2012
Code
[SIZE=2]I2C1Init( ); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* initialize I2c1 */[/COLOR][/SIZE][/COLOR][/SIZE]


[SIZE=2][COLOR=#3f7f5f]The port
[SIZE=2][COLOR=#3f7f5f][B][SIZE=2][COLOR=#3f7f5f]#define[/COLOR][/SIZE][/B][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PORT_USED 1[/COLOR][/SIZE]
[SIZE=2][COLOR=#000000]whenever will "1" ??[/COLOR][/SIZE]
[/COLOR][/SIZE]


[LEFT][SIZE=2]I2CWriteLength[PORT_USED] = 3;[/SIZE]
[SIZE=2]I2CReadLength[PORT_USED] = 0;[/SIZE]
[SIZE=2]I2CMasterBuffer[PORT_USED][0] = CI_ADDR; //A0 for Si570 VCXO of 10 MHz[/SIZE]
[SIZE=2]I2CMasterBuffer[PORT_USED][1] = 0x07; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* address */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[SIZE=2]I2CMasterBuffer[PORT_USED][2] = 0x55; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Data0 */[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]I2CEngine( PORT_USED );[/SIZE]


Thanks,
Bruno Braga
0 Kudos
Reply