View previous topic :: View next topic |
Author |
Message |
pasini
Joined: 12 Dec 2005 Posts: 50 Location: Curitiba - Brazil
|
I2C FORCE_HW PROBLEM |
Posted: Wed Jan 11, 2006 7:32 am |
|
|
MPLAB 7.30 + CCS 3.241 + PIC18F8680
When I do "#use i2c(master,sda=PIN_C4,scl=PIN_C3,FORCE_HW)" the I2C does not initialize. When I comment the FORCE_HW --> "#use i2c(master,sda=PIN_C4,scl=PIN_C3)", it works fine. The problem seams to be when there are multiple devices on the I2C lines (each one with different addresses, obviously).
Why is it ?
Thanks in advance.
Pasini |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 12, 2006 2:47 pm |
|
|
I looked at the .LST file for an i2c_write(), and also at the init code
for the i2c module, and it looks OK. The code looks the same as
they do for an 18F452 and a 16F877 in FORCE_HW master mode. |
|
|
pasini
Joined: 12 Dec 2005 Posts: 50 Location: Curitiba - Brazil
|
I2C FORCE_HW PROBLEM |
Posted: Fri Jan 13, 2006 4:31 am |
|
|
The problem is probably due to SDA and SCL voltage levels. At the pins, "1" is 5V but "0" is as high as 3.5V. I had 10k pullups but changed to 2k2 resistors; no difference. When I2C_start() is called I can see the voltage change in the pin from 5V to 3.5V. What can make a pin have such voltage levels ?
This is happening even if the is configured as I/O, and a function like output_toggle(PIN_C3) is called.
Thanks
Pasini |
|
|
Ttelmah Guest
|
|
Posted: Fri Jan 13, 2006 5:22 am |
|
|
Seriously, the obvious answer is that there is something else on the lines preventing them being pulled down. A gate on a device driving high, or a short somewhere. Impedance of probably about 60R. Test by removing the PIC, and pulling the line to ground with a 1K resistor. Given that you have a 2.2K pull up, the line should go down to about 1.6V. I2C stuff, is not meant to drive the lines high, but to rely on the pull-ups. If it does not drop to this sort of voltage, look elsewhere than the PIC...
Best Wishes |
|
|
pasini
Joined: 12 Dec 2005 Posts: 50 Location: Curitiba - Brazil
|
I2C FORCE_HW PROBLEM |
Posted: Fri Jan 13, 2006 10:01 am |
|
|
Yes, there was another I2C component that wasn´t in use but was soldered upsidedown. Soldering it correctly made I2C signals work properly.
Thanks for the help. |
|
|
|