2021-04-25 12:07 PM
Hi, pls help, I have rtc working, counting seconds, but I didn't succeded to make alarm work.
// the setup function runs once when you press reset or power the board
void setup() {
delay(500);
RTC_init(HOUR_FORMAT_24, LSI_CLOCK, 1);
//RTC_SetClockSource(LSI_CLOCK);
RTC_SetTime(0,0,0,0,HOUR_AM);
RTC_StopAlarm();
RTC_StartAlarm(0,0,0,10,0,HOUR_AM, OFF_MSK);
attachAlarmCallback((voidCallbackPtr)&alarm_cb,0);
// initialize digital pin PB1 as an output.
Serial.begin(9600);
pinMode(PC13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(PC13, HIGH);
delay(500);
digitalWrite(PC13, LOW);
delay(500);
uint8_t hours; uint8_t minutes; uint8_t seconds; uint32_t subSeconds; hourAM_PM_t period;
RTC_GetTime(&hours, &minutes, &seconds, &subSeconds, &period);
Serial.print(seconds);
Serial.println(" End");
}
void alarm_cb (){
Serial.println("Alarma");
delay(100);
}
2023-06-20 01:37 AM
Hi @IDine.1 ,
It seems you try to use the BSP part of the https://github.com/stm32duino/STM32RTC library.
You should avoid this and simply use the RTC instance as shown in the examples.