Page 2 of 2

Re: I2C alternate pin setting not working on STM32 core

Posted: Wed Oct 18, 2023 10:28 am
by ManX84
I FOUND THE PROBLEM !!

I back to basic and start from a simply blink working program.
When I add my previous I2C test code, it stop working (no blink !)
Then I remove my command one by one and discover than the .setClock is the problem !!

look at this code :

Code: Select all

/*
  Test i2C
*/

#include <Wire.h>

#define LED_BUILTIN PC13

TwoWire I2C_Alternate(PB9, PB8);
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  //!\ => if I set the I2C clock => Program stop to run !!
  //I2C_Alternate.setClock(400000);
  I2C_Alternate.begin();
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(500);                      // wait for a second

  I2C_Alternate.beginTransmission(4);
  I2C_Alternate.write(0xAA);
  I2C_Alternate.endTransmission();
}
it work and SCL on PB8 out the clock!
but if you uncomment the setClock, program no working anymore (no blink !)

What's wrong on this setClock ?
Could some people confirm this fact before I post an Issue ?

Thanks

Re: I2C alternate pin setting not working on STM32 core

Posted: Wed Oct 18, 2023 10:33 am
by ManX84
OK, here the solution : viewtopic.php?t=290 :idea:

The setClock command MUST be put AFTER the begin !!!!!! :shock: :shock: :shock: