Skip to content

RTClock implementation for STM32F103 #1946

Closed Answered by fpistm
abhaysbharadwaj asked this question in Libraries
Discussion options

You must be logged in to vote

you want something like a free running counter.
You can try something like this as a workaround

#include <STM32RTC.h>
#include "stm32yyxx_ll_rcc.h"

static int counter = 0;

//store the device up-time count
static unsigned long deviceOperationTime = 0;
static unsigned long offsetOPTime = 0;
STM32RTC& rtc = STM32RTC::getInstance();

void setup()
{
  Serial.begin(115200);
  Serial.println("Device Powered ON");
  rtc.begin();
  rtc.attachSecondsInterrupt(rtc_SecondsCB);
  dwt_init();
  enableBackupDomain();
  if(LL_RCC_IsActiveFlag_SFTRST() || LL_RCC_IsActiveFlag_PINRST()) {
    offsetOPTime += getBackupRegister(LL_RTC_BKP_DR2);
    LL_RCC_ClearResetFlags();
  } else {
    resetBackupDomain(…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@abhaysbharadwaj
Comment options

@fpistm
Comment options

Comment options

You must be logged in to vote
3 replies
@fpistm
Comment options

Answer selected by fpistm
@abhaysbharadwaj
Comment options

@fpistm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants