9 years, 11 months ago.

I2C issue with Nucleo 152RE

Hi,

I have a Nucleo 152RE which I want to act as a I2C master to control a I2C slave display. I successfully tried to print “Hello, world!” on the display from an Arduino Duemilanove with the following code:

Arduino code

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x3f for a 16 chars and 2 line display
void setup()
{
  lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
}
void loop()
{
}

According the Nucleo Manual ( http://www.st.com/st-web-ui/static/active/jp/resource/technical/document/user_manual/DM00105823.pdf ), I put the SB56,SB51 OFF and SB46,SB52 to ON, so to get PC1 and PC0 disconnected from A4 and A5 and PB9(SDA), PB8(SCL) connected to A4 and A5.

Connecting now the I2C slave display to the Nucleo and running the following code, I don’t get any result from the scan:

Scan code

#include "mbed.h"
 
I2C i2c(PB_9, PB_8);
Serial pc(SERIAL_TX, SERIAL_RX);

char data [255];
int i;
int main()
{
    pc.printf("started.. \n");
    // Scan for I2C devices that reply with ack
    for (i=0; i<=254; i=i+2) {
        if (i2c.read(i, &data[0], 1) ==0) 
        {
            pc.printf("I2C device detected at address=%2.2X\n\r", i);
        }
    }
}

Also measuring with the oscilloscope I don’t see anything going on. The voltage of the SCL and SCA is constantly 0V. The same happens if I connect the the I2C slave directly to PB8 and PB9.

As there’s nothing going on in the SCA and SCL line, I fear I missed a jumper setting.

Can someone give me an advice or has some experience in I2C on the Nucleo 152RE?

Thanks a lot in advance!

1 Answer

9 years, 11 months ago.

You may need external pull-up R's on the I2C lines. They should be configured as open-collector/open drain on the CPU pins and thus show 0V without pull-up.

Thank you for your answer! With a pull-up 10k resitstor on each SCL and SDA line, I get signals which looks more likely as I2C. But still I cannot communicate to the display slave. I need some investiogations into this from my site.

posted by Luca Somaini 12 May 2014