Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: remove RTC clock source selection for Nucleo_F446#1920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fpistm merged 1 commit intostm32duino:mainfromfpistm:F446_RTC
Jan 12, 2023

Conversation

fpistm
Copy link
Member

@fpistmfpistm commentedJan 11, 2023
edited
Loading

This prevents to reset the RTC backup domain when clock source is not the same and a poweroff with VBAT or software reset occurs. Moreover, LSI does not count when power off and VBAT so it is not useful.

Fixes#1919

Sketch used to test

Board: Nucleo F446RE with SB45 removed. Then connect external 3.3V to VBAT.

#include<STM32RTC.h>/* Get the rtc object*/STM32RTC& rtc = STM32RTC::getInstance();/* Change these values to set the current initial time   format: date: "Dec 31 2017" and time: "23:59:56"   by default use built date and time*/staticconstchar* mydate = __DATE__;staticconstchar* mytime = __TIME__;//static const char* mydate = "Dec 31 2017";//static const char* mytime = "23:59:56";static byte seconds =0;static byte minutes =0;static byte hours =0;staticuint32_t subSeconds =0;static byte weekDay =1;static byte day =0;static byte month =0;static byte year =0;static STM32RTC::Hour_Format hourFormat = STM32RTC::HOUR_24;static STM32RTC::AM_PM period = STM32RTC::AM;staticuint8_tconv2d(constchar* p) {uint8_t v =0;if ('0' <= *p && *p <='9')    v = *p -'0';return10 * v + *++p -'0';}// sample input: date = "Dec 26 2009", time = "12:34:56"voidinitDateTime (void) {  year =conv2d(mydate +9);// Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decswitch (mydate[0]) {case'J': month = (mydate[1] =='a') ?1 : ((mydate[2] =='n') ?6 :7);break;case'F': month =2;break;case'A': month = mydate[2] =='r' ?4 :8;break;case'M': month = mydate[2] =='r' ?3 :5;break;case'S': month =9;break;case'O': month =10;break;case'N': month =11;break;case'D': month =12;break;  }  day =conv2d(mydate +4);  hours =conv2d(mytime);if (hourFormat == rtc.HOUR_12) {    period = hours >=12 ? rtc.PM : rtc.AM;    hours = hours >=13 ? hours -12 : (hours <1 ? hours +12 : hours);  }  minutes =conv2d(mytime +3);  seconds =conv2d(mytime +6);}voidsetup(){  Serial.begin(9600);while (!Serial);initDateTime();// 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 formatif (!rtc.isTimeSet()) {    Serial.printf("RTC time not set\n Set it!\n");// Set the time    rtc.setTime(hours, minutes, seconds);    rtc.setDate(weekDay, day, month, year);  }else {    Serial.printf("RTC time already set\n");  }}voidloop(){  rtc.getTime(&hours, &minutes, &seconds, &subSeconds, &period);// Print date time  Serial.printf("%02d/%02d/%02d %02d:%02d:%02d.%03d\n", rtc.getDay(), rtc.getMonth(), rtc.getYear(), hours, minutes, seconds, subSeconds);delay(1000);}

This prevents the RTC clock to be reset when clock source is notthe same and a poweroff with VBAT or software reset occurs.Moreover, LSI does not count when power off and VBAT so it is notuseful.Fixesstm32duino#1919Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@fpistmfpistm added the fix 🩹Bug fix labelJan 11, 2023
@fpistmfpistm added this to the2.5.0 milestoneJan 11, 2023
@fpistmfpistm merged commit72524db intostm32duino:mainJan 12, 2023
@fpistmfpistm deleted the F446_RTC branchJanuary 12, 2023 08:17
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
fix 🩹Bug fix
Projects
None yet
Milestone
2.5.0
Development

Successfully merging this pull request may close these issues.

LSI not counting time while powered off, LSE backupdomain not working at all
1 participant
@fpistm

[8]ページ先頭

©2009-2025 Movatter.jp