I2C module of dsPIC - strange behavior...

Status
Not open for further replies.

Gobol

Member level 1
Joined
Sep 29, 2005
Messages
37
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Location
PL
Activity points
1,693
dspic i2c

Hi,

I've tried to use I2C module of dsPIC 30F6014A. I've used pic30 library <i2c.h> to perform I2C communication with 24AA1025 1Mbit serial eeprom from M*crochip.
I've spent many hours debugging, because it didn't work as it is suggested in datasheet and examples.

The initialization code is :
Code:
 baud = I2cBRG;	
 
 config1 = (I2C_ON & I2C_IDLE_CON & I2C_CLK_HLD & I2C_IPMI_DIS & I2C_7BIT_ADD &
		    I2C_SLW_DIS & I2C_SM_DIS & I2C_GCALL_DIS & I2C_STR_DIS &
			I2C_NACK & I2C_ACK_DIS & I2C_RCV_DIS &
			I2C_STOP_DIS & I2C_RESTART_DIS & I2C_START_DIS);
 OpenI2C(config1,baud);
 IdleI2C();

And the problem appear here :

Code:
 StartI2C();
 while(I2CCONbits.SEN ); // while start condition ... wait

It seems that the SEN bit is resetted too early, or not set fast enough, because this while-loop passes without any delay, even before the START condition is sent to I2C bus.

This situation applies to any bit (TBF, PEN, RSEN, ACKSTAT)...

Anybody has some suggestions ?

Thanks in advance.
Bogusz.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…