LPC17xx I2C

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

LPC17xx I2C

647 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by furkan.yuksel on Fri Jul 15 02:28:49 MST 2011
Hi,

I just tried to write my own i2c driver, but I couldn't even make my program get into I2C_IRQ.

My initializatin code for I2C1:
void I2CInit( )
{
      LPC_SC->PCONP |= (1 << 19);

      /* set PIO0.0 and PIO0.1 to I2C1 SDA and SCL */
      /* function to 11 on both SDA and SCL. */
      LPC_PINCON->PINSEL0 &= ~((0x3<<0)|(0x3<<2));
      LPC_PINCON->PINSEL0 |= ((0x3<<0)|(0x3<<2));
      LPC_PINCON->PINMODE0 &= ~((0x3<<0)|(0x3<<2));
      LPC_PINCON->PINMODE0 |= ((0x2<<0)|(0x2<<2));        /* No pull-up no pull-down */
      LPC_PINCON->PINMODE_OD0 |= ((0x01<<0)|(0x1<<1));    /* Open drain */

      /*--- Clear flags ---*/
      LPC_I2C1->CONCLR = I2C_AA | I2C_SI | I2C_STA | I2C_I2EN;

      LPC_I2C1->SCLL   = I2SCLL_SCLL;
      LPC_I2C1->SCLH   = I2SCLH_SCLH;

      LPC_I2C1->ADR0 = Slave_ADDR1_0;

      /* Enable the I2C Interrupt */
      NVIC_EnableIRQ(I2C1_IRQn);
      LPC_I2C1->CONSET = I2C_I2EN | I2C_AA;

}


My write code:

int i, timeout_flag;

    SLV_ADDR = slave_addr;

    for (i=0; i<data_length; i++)
        Master_Write_Buffer = write_buf;

    Master_Write_Length = data_length;
    Master_Write_Index = 0;


    I2C_Ready=0;
    LPC_I2C1->CONSET = I2C_STA;


any ideas?
0 Kudos
Reply
6 Replies

534 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Mon Jul 18 03:25:34 MST 2011
Thanks,

The price is ok (25 euro).
Just one minor drawback... at the moment not available in Europe :D (I looked at the websites of the official import companies)

But it's worth considering.
0 Kudos
Reply

534 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by behzat_c on Mon Jul 18 01:42:23 MST 2011

Quote: Serge

If anyone has a better and or cheaper solution then i want to know :p



You can try Bus Pirate. It's cheaper (around 30$) and much more capable.

http://en.wikipedia.org/wiki/The_Bus_Pirate

http://www.seeedstudio.com/depot/bus-pirate-v3-assembled-p-609.html?cPath=174
0 Kudos
Reply

534 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Mon Jul 18 00:05:39 MST 2011
I am using the Microchip PicKit Serial Analyser for this purpose.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en028600

I don't think it does the fast mode plus but hey ... it costs only 35 euro (plus taxes).

If anyone has a better and or cheaper solution then i want to know :p
0 Kudos
Reply

534 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Sun Jul 17 12:48:58 MST 2011
Hello furkan.yuksel,

suggestion ... when you play with IIC, try to use some analyzing device, to see what happens, what data is being send etc.

Did you compare your software with the code-bundle on the website?

see: http://ics.nxp.com/support/documents/microcontrollers/?locale=en,,Latn&type=software

(...)
0 Kudos
Reply

534 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by furkan.yuksel on Fri Jul 15 06:10:39 MST 2011
Never mind, again one of my stupid mistakes one more time :D
0 Kudos
Reply

534 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by furkan.yuksel on Fri Jul 15 05:28:42 MST 2011
Ok, problem changed now.

This time, my master sends data but in first connection slave gets into state 0xF8.

I read manual and it says if state is at 0xF8, SI is not yet set. But if SI not set, how this program gets into IRQ.

Best Regards,

Furkan Yuksel
[email]furkan.yuksel@akya.net[/email]
0 Kudos
Reply