cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Alarm not working on stm32duino

IDine.1
Associate

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);

}

1 REPLY 1
UnderGnd
ST Employee

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.

https://github.com/stm32duino