??? 08/12/06 03:20 Read: times |
#122110 - I2C interface with 89LPC9221 Responding to: ???'s previous message |
Hi Erik,
I agree with you. I'm not copying any code here. Just to understand how i2c is functioning through some code example. I am writing my own i2c routine to interface with 24C64A. But it seems that when i issue a START condition, my SDA pin and SCL pin always low. I have developed one with 89C61X2 which use port pin to generate SCL and SDA waveform and is working. However when i switch to 89LPC9221, which comes with i2c facilities with clk rate of 400kHz, my program is not running. Just to clarify with you whether it works like that: In order to generate a START condition, I2CON = 0b01000001;//use timer 1 as SCL clkrate, I2EN = 1 I2CON = I2CON | 0b00100000;//STA = 1 wait there until I2C interrupt generated (SI=1) in I2C interrupt, monitor value of I2STAT, perform action as stated in datasheet. Clear SI and RETI. This my understandings on the i2c of 89LPC9221. Am i correct? Why is it when the program runs, the SCL and SDA pin always low? Note that i have pull-high both pins with resistor 10K to 3.3V. The pins are configured as push-pull. When i stop running i2c routine, the pins go high again. Please help. Regards, Ivan |