I2C0 initialization

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

I2C0 initialization

230 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Thu Jan 06 05:53:04 MST 2011
I've been trying to set up I2C0 on my RDB1768 board. Here is my initialization code: (From what I have read in the UM10360, this should be enough to start the clock generation on the SCL pin, please correct me if I'm wrong)

void i2cInitPins()
{
    LPC_PINCON->PINSEL1 |= ~(2 << 22);
    LPC_PINCON->PINSEL1 &= ~(2 << 24);
    LPC_PINCON->I2CPADCFG = 0;
}

void i2cInit()
{
    LPC_SC->PCONP |= (1 << 7);
    LPC_SC->PCLKSEL0 = 1 << 14;

    LPC_I2C0->I2SCLH = 125;
    LPC_I2C0->I2SCLL = 125;

    LPC_I2C0->I2CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;

    NVIC_EnableIRQ(I2C0_IRQn);

    LPC_I2C0->I2CONSET = I2CONSET_I2EN;    
}


When I scope the SCL pin, I only see it high.

Renan
0 Kudos
2 Replies

171 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Thu Jan 06 07:46:22 MST 2011

Quote:

Do you expect to see a permanent clock signal? Then you are wrong.

That is what I was expecting... Glad to read that I'm wrong.

Thanks
Renan
0 Kudos

171 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jan 06 06:30:18 MST 2011
This can't work
Try:
PINSEL1 &=~((3<<22)|(3<<24)); //clear sel bits
PINSEL1 |= ((1<<22)|(1<<24)); //set SDA0,SCL0



Quote:
this should be enough to start the clock generation on the SCL pin, please correct me if I'm wrong)



Do you expect to see a permanent clock signal? Then you are wrong.

You can find also an I2C sample in:

http://ics.nxp.com/support/documents/microcontrollers/zip/code.bundle.lpc17xx.keil.zip
0 Kudos