Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
3 years, 2 months ago.
I2C not working, Parallel bus works
Hi, Hen I hook a 20x4 LCD to mbed p15-p20 It works.
I end up with a report on the USBterminal and 4 lines that start with a line number, some asterisks and a + symbol at the end. The first line also contains two facing triangles as chars 1 (triangle points right) and 2 (triangle points left)
If I use http://www.ebay.com/itm/291780291995?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT I get nothing.
The PCB has a genuine Philips PCF8574AT.
I tried: -modules 'default' and 'lcm1602' -addresses 0x20, 0x27, 0x40, 0x4E and 0x38, 0x3F, 0x70, 0x7E -2k2 resistor pll-ups on SDA and SCL to +3v3 (do I need 5v?)
I probed the I2C IO and I get a legible address byte followed by an uninterpretable byte on my scope/protocol analyzer.
Where am I going wrong?
Question relating to:
3 years, 2 months ago.
The ebay page shows a module with the PCF8574. That device has a default I2C address 0x4E (mbed format) since by default the module sets A0-A2 at logic high. However, I have seen the same module with the PCF8574A. The default address for that version is 0x7E (mbed format). Looks like you have that type. The analyser will only display the slaveaddress and no data because the mbed I2C routines dont get an Ack from the slave and abort.. The Ack (bit 9 of a communication frame) is missing (high level) because the Slaveaddress is wrong.
Try this approach:
First update the TextLCD lib (right click on the lib in your project) to make sure you have the latest version
Open the lib and adapt the TextLCD_config.h file, select LCM1602:
//Pin Defines for I2C PCF8574/PCF8574A or MCP23008 and SPI 74595 bus expander interfaces //Different commercially available LCD portexpanders use different wiring conventions. //LCD and serial portexpanders should be wired accordingly. // //Select Serial Port Expander Hardware module (one option only) #define DEFAULT 0 #define ADAFRUIT 0 #define DFROBOT 0 #define LCM1602 1 #define YWROBOT 0 #define GYLCD 0 #define MJKDZ 0 #define SYDZ 0 #define WIDEHK 0 #define LCDPLUG 0
Declare the display:
TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C bus, PCF8574A Slaveaddress, LCD Type
Compile and run the code
Make sure the LCD contrast is correct. Adjust the blue potentiometer on the i2C portexpander module. Voltage on pin 3 of the LCD will be close to 0.5 V but that depends on the LCD. What contrast voltage did you use for the parallel port version? You will probably already see dark rectangles on the display when the power is on, even without running any code.
That should work..