cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-G474re Arduino I2C not working.

BCunn.1
Associate

I'm trying to do a quick eval of a NUCLEO-G474re board for use of the SoC as a product communication controller (I2C, SPI, RS-485, etc.), initially using the Arduino environment for rapid testing. Initial attempt to bring up I2C causes NO activity on SCL/SDA as observed on a logic analyzer.

Relevant code fragments for a DS1683 at 7-bit address 0x6B:

#include <Wire.h>

Wire.begin(); // SCL/SDA on Arduino D15/D14 (G474 PB8/PB9)

 Wire.setClock(100000L); // 100 kHz

 Wire.beginTransmission(0x6B);

 Wire.write(0x01); // Check the Status register

 Wire.requestFrom(0x6B, 1);

 byte RegData = Wire.read();

 Wire.endTransmission();

Am I missing something obvious? Why is the I2C bus quiet?

Thanks!

Edit: Downloaded an I2C Scanner sketch. No I2C activity on the NUCLEO, but works on an Arduino Due.

-BobC

1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

Hello @BCunn.1​ ,

You can refer to this article : STM32 Arduino (STM32duino) Tutorial (site.com)

#include <Wire.h>
 
void setup() {
 Wire.begin();                
 Serial.begin(9600);    
 Wire.setClock(100000);
 Wire.beginTransmission(deviceAddress);    // get the sensors attention 
 Wire.write(registerAddress);    // move your memory pointer to registerAddress
 Wire.endTransmission();           // completes the ‘move memory pointer’ transaction
int data = 0;
}
 
void loop() {
Wire.requestFrom(deviceAddress, 1); // send me the data from the register
data = Wire.read();             // data from registerAddress
Serial.println(data);   // print the reading
 }

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Foued_KH
ST Employee

Hello @BCunn.1​ ,

You can refer to this article : STM32 Arduino (STM32duino) Tutorial (site.com)

#include <Wire.h>
 
void setup() {
 Wire.begin();                
 Serial.begin(9600);    
 Wire.setClock(100000);
 Wire.beginTransmission(deviceAddress);    // get the sensors attention 
 Wire.write(registerAddress);    // move your memory pointer to registerAddress
 Wire.endTransmission();           // completes the ‘move memory pointer’ transaction
int data = 0;
}
 
void loop() {
Wire.requestFrom(deviceAddress, 1); // send me the data from the register
data = Wire.read();             // data from registerAddress
Serial.println(data);   // print the reading
 }

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.