Not reproducable. Using
[env:genericSTM32F103RE]
platform = ststm32
board = genericSTM32F103RE
framework = arduino
upload_protocol = serial
upload_speed = 115200
lib_deps =
khoih.prog/TimerInterrupt_Generic@^1.5.0
fmalpartida/LiquidCrystal@^1.5.0
stm32duino/STM32duino RTC @ ^1.1.0
and
#include <LiquidCrystal_I2C.h>
#include <STM32RTC.h>
/* Get the rtc object */
STM32RTC& rtc = STM32RTC::getInstance();
/* Change these values to set the current initial time */
const byte seconds = 0;
const byte minutes = 0;
const byte hours = 16;
/* Change these values to set the current initial date */
/* Monday 15th June 2015 */
const byte weekDay = 1;
const byte day = 15;
const byte month = 6;
const byte year = 15;
void setup()
{
Serial.begin(9600);
// Select RTC clock source: LSI_CLOCK, LSE_CLOCK or HSE_CLOCK.
// By default the LSI is selected as source.
//rtc.setClockSource(STM32RTC::LSE_CLOCK);
rtc.begin(); // initialize RTC 24H format
// Set the time
rtc.setHours(hours);
rtc.setMinutes(minutes);
rtc.setSeconds(seconds);
// Set the date
rtc.setWeekDay(weekDay);
rtc.setDay(day);
rtc.setMonth(month);
rtc.setYear(year);
// you can use also
//rtc.setTime(hours, minutes, seconds);
//rtc.setDate(weekDay, day, month, year);
}
void loop()
{
// Print date...
Serial.printf("%02d/%02d/%02d ", rtc.getDay(), rtc.getMonth(), rtc.getYear());
// ...and time
Serial.printf("%02d:%02d:%02d.%03d\n", rtc.getHours(), rtc.getMinutes(), rtc.getSeconds(), rtc.getSubSeconds());
delay(1000);
}
the result is
PLATFORM: ST STM32 (14.0.0) > STM32F103RE (64k RAM. 512k Flash)
HARDWARE: STM32F103RET6 72MHz, 64KB RAM, 512KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
- framework-arduinoststm32 4.20000.210603 (2.0.0)
- framework-cmsis 2.50700.210515 (5.7.0)
- toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 13 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <TimerInterrupt_Generic> 1.6.0
|-- <LiquidCrystal> 1.5.0
| |-- <Wire> 1.0
|-- <STM32duino RTC> 1.1.0
Building in release mode
Compiling .pio\build\genericSTM32F103RE\FrameworkArduinoVariant\PeripheralPins.c.o
[..]
Linking .pio\build\genericSTM32F103RE\firmware.elf
Checking size .pio\build\genericSTM32F103RE\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 1.5% (used 988 bytes from 65536 bytes)
Flash: [ ] 3.5% (used 18104 bytes from 524288 bytes)
Building .pio\build\genericSTM32F103RE\firmware.bin
============= [SUCCESS] Took 11.17 seconds =============
Make sure the platform, framework and library version match what’s in my build log above.