I2C LCD with PCF8574 hangs the firmware

Hello,

I'm using repetier firmware 0.92.8 on a Gen7 1.4 with ATMega 1284P at 20Mhz. All works fine, included the SD card but I'm not able to use the 20x4 LCD display with the I2C protocol and PCF8574.

I defined UICONFIG_CONTROLLER in Configuration.h and in UIconfig.h:

UI_DISPLAY_TYPE 3

UI_DISPLAY_I2C_CHIPTYPE 0

UI_DISPLAY_I2C_ADDRESS 0x40  (the A0 A1 A2 pins of the PCF8574 are a ground).

I tried also the address 0x20, 0x21, 0x41....

I put also 2 pull-up resistor on the SCL and SDA lines as the I2C specifications but when I load the firmware with this configuration, the firmware hangs and no USB connection is available.

Can you help me ?

Thanks in advance

Fabrysan

Comments

  • With I2C you get a hang if no device with given address is found. There is no timeout.

    Have you also tried 0x4e with all addresses identical it should be 0x40 or 0x4e








  • At the begining: in the comment on the i2c address :


    // 0x40 till 0x4e for PCF8574, 0x40 for the adafruid RGB shield, 0x40 - 0x4e for MCP23017
    // Official addresses have a value half as high!
    #define UI_DISPLAY_I2C_ADDRESS 0x4e

    that means You need to multiplicate the real address by 2. My pcf has manufacturer address 0x27, and 0x27 *  gives 0x4e.

    with 0x27 the firmware freezes while with 0x4e appears to communicate well.

    regards

    dev

  • Hi dev,

    I tried:

    #define UI_DISPLAY_I2C_ADDRESS 0x4e but the firmware freezes again.
    Can you explain me what do you mean with "You need to multiplicate the real address by 2" ?

    From the datasheet of the PCF8574 I can read that the manufacturer address is 0x40 plus the value set to the pins A0 A1 and A2. My pins are all connected to ground so the address should be 0x40.

    Have I to multiply the default value (0x40) by 2 ? so... have I to try the 0x80 address ?

    Thanks for your time and your help.

  • Looking in the PCF8574 datasheet I red that with the user pin to ground, the 7bit address without R/W bit is 0x20. The write address is 0x40 and the read address 0x41.

    I presume that the right value is the 7bit value 0x20 and muntiplied by 2 should be 0x40.

    I tried several times the 0x40 address without success.

    Probably I wrong something else...

    Is there some library to include in repetier.ino for the correct use of the display and/or I2C ?

    I modified only the configuration.h pins.h and uiconfig.h.

    Fabrysan

  • You shift the normal address and the lowest bit is the read/write bit. We use the shifted address so 0x20 becomes 0x40 and 0x27 becomes 0x4e depending on all pins gnd or 5v.

    Repetier has it's own I2C library it uses if you selected that display type. There is also a display type for liquid crystal which requires it to be included in repetier.ino and uses the lower addresses instead.
  • Finally,

    I uploaded the sketch "I2C scanner" on the board and I found that ... my PCF8574 answer at address 0x38 ???

    This probably is a chinese clone... tried another set of chips and they correctly answered at 0x20.

    So, set the firmware address to 0x40 and put two 10k pull-up resistors on SCL and SDA lines, all works fine !!!

    SOLVED.

Sign In or Register to comment.