cancel
Showing results for 
Search instead for 
Did you mean: 

I2C does not work with Arduino IDE and STM32L152

PStol.1
Associate

Hi,

I tried the following program:

#include <Wire.h>
 
void setup()
{
Wire.begin(); //creates a Wire object
// set I/O pins to outputs
Wire.beginTransmission(0x20); // MCP 23008 Port Expander
Wire.write(0x00); //selects the IODIRA register
Wire.write(0x00); //this sets all port A pins to outputs
Wire.endTransmission(); //stops talking to device
}
 
void loop()
{
Wire.beginTransmission(0x20); 
Wire.write(0x09); //selects the GPIO pins
Wire.write(0xFF); // turns on pins 0 and 1 of GPIOA
Wire.endTransmission(); //ends communication with the device
}

I use D15 (SCL) ans D14 (SDA) with a Microchip PKSerial-I2C1 demoboard. Program does not work.

Can somebody please help?

Dear Peter

1 ACCEPTED SOLUTION

Accepted Solutions
PStol.1
Associate

Thanks for your help. I found the solution. The Nucleo RET152 Board has 3.3V outputs. The demoboard needs 5 V.

Dear Peter

View solution in original post

3 REPLIES 3
HA.5
Associate III

Hi,

what do you mean exactly? it mean's you get error? if yes what kind of error do you have?

Not sure why it's writing the same register repeatedly in the loop

You seem to ignore all error or status returns from the functions.

Perhaps instead of "does not work" you can expand a little on what does and does not happen.

Perhaps look at signals at a bus level, and what errors/failures the functions are reporting.

You have suitable pull-ups on the pins?

Can you output information to Serial?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
PStol.1
Associate

Thanks for your help. I found the solution. The Nucleo RET152 Board has 3.3V outputs. The demoboard needs 5 V.

Dear Peter