How To get internal RTC time using STM8L050J3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-12 2:46 AM
Hi All,
We are using the STM8L050J3 chip and trying to get time using an internal RTC with LSI. We are getting some responses but are not sure what it is. Here is our result (TIME: 3108:4877:2644) and code. We are using the cosmic compiler. Could anyone help me make it correct and point out where the issue is? All support is hugely appreciated.
Code:
and output is:
////OUTPUT /////
TIME: 3107:13069:2644
A
TIME: 3107:14861:2644
A
TIME: 3108:1293:2644
A
TIME: 3108:3085:2644
A
TIME: 3108:4877:2644
*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-13 10:09 AM
printf %d expects an integer argument and RTC_Hours, RTC_Minutes and RTC_Seconds are character variables.
Try this:
printf("Time: %02d:%02d:%02d\n", (uint16_t)time.RTC_Hours (uint16_t)time.RTC_Minutes, (uint16_t)time.RTC_Seconds);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-14 10:10 PM
Thanks for the reference.
there was a conversion issue same we solved. Now we have encountered another issue of accuracy. we are using internal clock LSI. what should be expectations and how we can bring the best possible accuracy?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-17 12:34 PM
See AN3133 page 20: "LSI accuracy is not suitable for calendar application". RTC clock usually is LSE 32.768 KHz.
