I can't solve I2C and SPI
Posted: Thu Feb 06, 2025 9:30 am
Hi!
I have been using the Arduino platform for many years, but this is my first time with STM32. After several days of torment (yes, also with ChatGPT support) I decided to ask for help. I have a STM32F103C8T6 board (identified as MapleMini in PC) and I have tried to use I2C - every time the board stops working correctly. I have localized the root of the problem in a primitive sketch with the Wire.h library. It works correctly until the Wire.begin() command is removed - the Built In LED blinks and HELLO is received on the Serial Monitor. When Wire.begin() is added, the LED blinks, but the Serial Monitor does not receive anything. It seems that similar manifestations were also observed with SPI attempts. The board was uploaded via ST-Link from Arduino IDE v.1.8.13 for testing.
I think that Wire.h changes the pins to Serial output. Maybe I should use another library? Which one? Maybe the pins to Serial can be restored? Which ones and how?
Thanks for help.
I have been using the Arduino platform for many years, but this is my first time with STM32. After several days of torment (yes, also with ChatGPT support) I decided to ask for help. I have a STM32F103C8T6 board (identified as MapleMini in PC) and I have tried to use I2C - every time the board stops working correctly. I have localized the root of the problem in a primitive sketch with the Wire.h library. It works correctly until the Wire.begin() command is removed - the Built In LED blinks and HELLO is received on the Serial Monitor. When Wire.begin() is added, the LED blinks, but the Serial Monitor does not receive anything. It seems that similar manifestations were also observed with SPI attempts. The board was uploaded via ST-Link from Arduino IDE v.1.8.13 for testing.
I think that Wire.h changes the pins to Serial output. Maybe I should use another library? Which one? Maybe the pins to Serial can be restored? Which ones and how?
Code: Select all
#include <Wire.h>
TwoWire WIRE1 (PB11, PB10); //SDA=PB11 & SCL=PB10 or PB9 & PB8 or PB7 & PB6
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
// WIRE1.begin();
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
Serial.println("HELLO");
}