View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
I2C timeout for master |
Posted: Mon Jan 21, 2008 11:43 am |
|
|
I'm using an 18F452 that talks I2C to other devices. I was testing with nothing attached and noticed that with no slave attached the master locks up when it tries to write.
Here is the relevant code
#use I2C(master, sda=PIN_c4, scl=PIN_c3,slow)
i2c_start(); // restart condition
i2c_write(address);//address
i2c_write(16);//P is 16th letter
i2c_write(20);//pwm
i2c_write(0);//dir
i2c_write(20);//pwm
i2c_write(0);//dir
i2c_stop();
Is this normal? If so is there an easy way to make so I can test with nothing attached?
Thanks
Ringo _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 21, 2008 12:16 pm |
|
|
You probably don't have pull-ups on the master side. If you have
pull-ups, the master won't lock up with your test code, even though
there is no slave. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Mon Jan 21, 2008 12:52 pm |
|
|
I'll check tonight. The board is mostly populated, so it is possible I forgot to put them on.
Thanks
Ringo _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 21, 2008 12:55 pm |
|
|
Or, you might only have pull-ups on the detachable slave board. If so,
you could add some light pull-ups on the master board (such as 10K).
They would pull up the i2c lines when the slave is detached. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Mon Jan 21, 2008 1:06 pm |
|
|
The pads for the pullups are on my master board, but I might not have populated them yet. I'm assembling and testing at the same time, so I might have skipped over them.
Thanks
Ringo _________________ Ringo Davis |
|
|
xa4
Joined: 04 Jun 2008 Posts: 9
|
|
Posted: Wed Oct 29, 2008 9:39 am |
|
|
Greetings,
I have the same problem as Ringo but the pullup resistors (4k7) are present on my master circuit board..
Any ideas ?
Thank you ! _________________ Best,
Xavier Righetti - http://xa4.ch |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 29, 2008 3:13 pm |
|
|
1. Post the manufacturer and part number of the i2c chip that you are using.
2. Post a link to a schematic of your board (if possible).
3. Post a very small program that shows the problem.
4. Post your CCS compiler version. |
|
|
|