Use I2C library and I2C LCD library, simultaneously...

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I try to add a DTMF generator with I2C interface in a project that already uses LCD with the same interface. The problem is that I have to use lcd i2c library for the DTMF and also the i2c lcd library for LCD and somewhere is a conflict. Compiler is CV. The DTMF generator works, but not correctly. LCD seems to be ok... Any suggestion please ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There should be no problem. Make sure you have external pull-up resistors e.g. 4k7
What is the Slave address of the DTMF generator?
What is the address of the LCD i2c backpack? This is easy to change.
.
You can only talk to one i2c device at a time. The Codevision TWI library will do this for you.
If you use the bit-banged I2C library, you must remember to i2c_stop() before you change to the other device.
.
As always, USE the return values from the library functions. Then you know if there is an error.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David, thank you for your reply !

 

I forgot to write that of course the addresses are NOT the same. I can not change DTMF IC address (0x80), but I can do that as far as PCF8574 (I2C LCD) is concerned.

Yes there are 4K7 pull-up resistors, for both ICL and CLK lines.

 

What do you mean by "USE the return values" ? Ηοw to do that ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The return values indicates the status of how the operation completed, i.e. if it was successful or failed. If e.g. a call to some initialization function fails then there is no point in calling subsequent functions for e.g. sending or receiving. So you pick the return value from every call to the i2c functions, test for success and act accordingly.

Sometimes the return value in not simply success/fail, but for failure give further details on what the failure was. Use this to your advantage while debugging.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]