I2C alternate pin setting not working on STM32 core (solved)

Post here first, or if you can't find a relevant section!
User avatar
ManX84
Posts: 20
Joined: Tue Oct 17, 2023 3:30 pm

Re: I2C alternate pin setting not working on STM32 core

Post 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
Exposing your opinion is good, exposing your code is better! :mrgreen:
User avatar
ManX84
Posts: 20
Joined: Tue Oct 17, 2023 3:30 pm

Re: I2C alternate pin setting not working on STM32 core

Post by ManX84 »

OK, here the solution : viewtopic.php?t=290 :idea:

The setClock command MUST be put AFTER the begin !!!!!! :shock: :shock: :shock:
Exposing your opinion is good, exposing your code is better! :mrgreen:
Post Reply

Return to “General discussion”