I2C with MCP23008 in LPC1752

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

I2C with MCP23008 in LPC1752

743件の閲覧回数
jahid_sawikot
Contributor I

To use external resistor mcp23008 is working perfectly. But I want to use an internal resistor. With internal resister it's not working. 

void I2CInit() {


LPC_GPIO0->FIODIR0 |= 0x33; //P0.5 P0.4 P0.1 P0.0 ext pins 29,30,10,9
LPC_SC->PCONP |= 1 << 19; //re-enable POWER to I2C_2 if required
LPC_SC->PCLKSEL1 |= 1<<6; //pclk = cclk
LPC_PINCON->PINSEL0 |= 0x3<<0; //Pin P0.10 allocated to alternate function 2
LPC_PINCON->PINSEL0 |= 0x3<<2; //Pin P0.11 allocated to alternate function 2
LPC_GPIO0->FIODIR |= (1<<0); //Bit P0.10 an output
LPC_GPIO0->FIODIR |= (1<<1); //Bit P0.11 an output
LPC_PINCON->PINMODE0 &= ~(3<<0); //P0.10 has pull up/down resistor
//LPC_PINCON->PINMODE0 |= (2<<0); //omit to use internal pull up
LPC_PINCON->PINMODE0 &= ~(3<<2); //P0.11 has pull up/down resistor
//LPC_PINCON->PINMODE0 |= (2<<2); //omit to use internal pull up
LPC_PINCON->PINMODE_OD0 |= (1<<0); //Bit P0.10 is open drain
LPC_PINCON->PINMODE_OD0 |= (1<<1); //Bit P0.11 is open drain
LPC_I2C1->I2SCLH = 60; //100kHz from 12MHz
LPC_I2C1->I2SCLL = 60; //100kHz from 12MHz


}

ラベル(1)
0 件の賞賛
返信
1 返信

686件の閲覧回数
diego_charles
NXP TechSupport
NXP TechSupport

Hi Jahid, 

I still recommend  you to use an external pull-up resistor to guarantee proper signaling on the I2C line.

Looking at your code I have noticed that you enabled the Open Drain Mode  and pull up resistors  for P0,0 and P0.1  (SCL1 and SDA1)  When OD is set an external pull up is recommended, because the MCU internal pull up resistors are generally weak (at least 50K ohms).

Regards, Diego.

0 件の賞賛
返信