I2C Interrupt

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

I2C Interrupt

1,373 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by adrian0211 on Fri Mar 14 15:03:10 MST 2014
Hello,
I need help with the i2c bus. First i implemented the initializing:
void I2C_Init()
{
LPC_SYSCON->PRESETCTRL |= PRESETCTRL_I2C_RST_N;// I2C reset de-asserted
LPC_SYSCON->SYSAHBCLKCTRL |= SYSAHBCLKCTRL_I2C;// Enables Clock for I2C

LPC_IOCON->PIO0_4 |= 0x10;// I2C SCL
LPC_IOCON->PIO0_5 |= 0x10;// I2C SDA

LPC_I2C->CONCLR |= I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;//Init I2C Reg

LPC_I2C->SCLL   = I2SCLL_SCLL;// configuration I2C Bus Frequency
LPC_I2C->SCLH   = I2SCLH_SCLH;// configuration I2C Bus Frequency

NVIC_EnableIRQ(I2C_IRQn); // Enable the I2C Interrupt

LPC_I2C->CONSET = I2CONSET_I2EN;//Enable I2C Interface

return;
}

That seems to work. ...Then I wrote an I2C_IRQHandler to handle the interrupt states. (I use the microcontroller as Master only!)
The implemented states are 0x8, 0x10, 0x18, 0x28,...
After setting the Startbit I expected a state of 0x8. The manual says that the SI (interruption) bit is set automatically.
But I neither get a state of 0x8 nor enter the interrupt routine.

Would be thankful for some help.
If you want to see some more code i can publish the hole project.


Adrian




标签 (1)
0 项奖励
回复
1 回复

1,099 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Thu Apr 10 11:05:07 MST 2014
Hi, Adrian,


I would suggest you check the ICCON setting for P0_4 and P0_5, I suspect they are wrong so the I2C functionality are not activated:

try:
LPC_IOCON->PIO0_4 &= ~0x3F;/*  I2C I/O config */
LPC_IOCON->PIO0_4 |= 0x01;/* I2C SCL */
LPC_IOCON->PIO0_5 &= ~0x3F;
LPC_IOCON->PIO0_5 |= 0x01;/* I2C SDA */

Good luck!
0 项奖励
回复