RTC in STM32 || LCD 16x2 || HAL || CubeMx

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ม.ค. 2025

ความคิดเห็น • 129

  • @ControllersTech
    @ControllersTech  3 ปีที่แล้ว +3

    1. For backup register you can write any value you want. Just make sure you check for the same value after reset.
    2. Obviously you need an external battery, if you want to keep time when the controller is off. You can connect a 3V battery to Vbat pin.
    3. The RTC in F103C8 have some issues with keeping date. I can't do anything about it.. it needs to be fixed from ST.

    • @fernandocatalani8295
      @fernandocatalani8295 2 ปีที่แล้ว

      I do have 3V conected to Vbat pin. The Registers go back to initial values when the power is turned off... Any idea?

    • @rickyaryadi8422
      @rickyaryadi8422 5 หลายเดือนก่อน

      number 3 really can't be solved :(

    • @rickyaryadi8422
      @rickyaryadi8422 5 หลายเดือนก่อน

      i use f411ceu6 succeed

  • @elmir_rr
    @elmir_rr 2 ปีที่แล้ว

    All your videos are so clear and understandable you are very good about this.

  • @7tsu802
    @7tsu802 5 ปีที่แล้ว +4

    So helpful ! Thank you so much. I did succeeded to run RTC on STM32f103c8t6.

    • @LuisReyes-zg7mq
      @LuisReyes-zg7mq 4 ปีที่แล้ว

      How did you do it? I can't make It works

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      Which controller you have ?

    • @masterzerox2009
      @masterzerox2009 4 ปีที่แล้ว

      What backup register do you used?

  • @my_google_arifkhan9358
    @my_google_arifkhan9358 4 ปีที่แล้ว

    my code works fine but how can i make time to 00:00:00 and than increase or decrease the time and than set it to any value manualy and than escape

  • @justSdat
    @justSdat 3 ปีที่แล้ว +1

    I followed your example and applied it on my F030R8. I cannot set the time and date. It always starts from 00:00:00 and 01.01.00
    The same issue applies to the alarm.
    Also I have an error when I try to use the backup register command.
    Do you have any idea why this is happening?
    Also, thank you very much for the time spent on the videos, they are amazing and the most helpful.

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      Check your manual if it have backup registers. Also see the size, it might be small.
      There is one more way, without backup register.
      you set the time, flash the code, comment out the set time function and flash the code.

    • @justSdat
      @justSdat 3 ปีที่แล้ว

      @@ControllersTech Thank you for the response. Unfortunately I did not find a backup register in the manual and Flashing, commenting and flashing again, does not work either for setting the time and data, nor the alarm time.

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      I don't know what you are doing. Flashing thing works pretty well. I have tried it in many situations and it always worked.
      It's basically the same thing as using a backup register.
      Make sure your rtc initialisation function Doesn't set the time. Or else it will reset the time whenever you reset the board.

  • @sysHW
    @sysHW 6 ปีที่แล้ว +2

    Thank you man, God bless you. This video so useful .

  • @bautroiEM
    @bautroiEM 10 หลายเดือนก่อน

    could you build perpetual calendar in STM32 please

  • @dioadadosite4516
    @dioadadosite4516 2 ปีที่แล้ว

    How can I make the code to read the data from my bmp280 sensor on an lcd display like the one you used?... I can't find the code.

  • @maxiking3487
    @maxiking3487 9 หลายเดือนก่อน

    Hi, i am working on a NUCLEO Board with STM32L433. I use the LSE oscillator as clock for the RTC. I have connected a capacitor to the Board and removed SB61. The capacitor gets charged by the Board (i selected 1.5 kOhms resistor). The RTC works fine, but when i press the reset button, the RTC gets reset. Writing and Reading the BR works but after a system reset there is another value than 0x32F2 in the BR and i do not knwo why. Can you help me with this problem?
    Thanks in advance
    Max

  • @devjeetmandal1472
    @devjeetmandal1472 5 ปีที่แล้ว

    First of all thanks for the video. I just have one single doubt. At 4:59, what is the deal with 0x32F2 while setting the backup register? According to the function declaration, it is the data part, then why this data part is 0x32F2.
    Regards

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว +1

      It's a constant value need to be written in the backup register. Kind of a way to check whether the rtc was configured properly, before it backs up the data. Why 32f2 ? I really have no idea why that particular value only. It was there in cubemx by default. So i picked it up

  • @youssefosama4466
    @youssefosama4466 2 ปีที่แล้ว

    do i just connect a 3.3v to v bat if i want to keep track of time when the controller is off ?
    what is the code i need to achieve that ?

  • @MortezaGhorbani-j3q
    @MortezaGhorbani-j3q ปีที่แล้ว

    Thank you man, Please Make a Video on External Crystal RTC Calibration

  • @remellarnvssaditya9411
    @remellarnvssaditya9411 10 หลายเดือนก่อน

    Can i do this using a STM32F207VCT6 Uc? or do i need to change the clock configuration?

  • @bayuyutub5206
    @bayuyutub5206 2 ปีที่แล้ว

    hello..
    i'm using NucleoL412KB and it's code not work
    always my rtc time is reset..
    please help me..
    i'm using stanby mode

  • @TheJosele6
    @TheJosele6 4 ปีที่แล้ว

    Hello, how can I program an alarm for all days of the week?
    Thank you for the video!!

  • @Crazy-vk5sl
    @Crazy-vk5sl 6 ปีที่แล้ว

    Thank you. How to set multiple alarms?

  • @giannidellaratta6141
    @giannidellaratta6141 9 หลายเดือนก่อน

    I'm sorry to disturb you, but despite using the battery and regularly accessing the reading and writing of time and date, I have the problem that after any reset, even from debug, I lose the date information, while the clock continues without any problem, I could you help? Thank you

    • @ControllersTech
      @ControllersTech  9 หลายเดือนก่อน

      Which mcu ?

    • @giannidellaratta6141
      @giannidellaratta6141 9 หลายเดือนก่อน

      STM 32F103Ret thanks​@@ControllersTech

    • @ControllersTech
      @ControllersTech  9 หลายเดือนก่อน

      Its a known issue in f103 series. As far as I know, it can't be fixed. You need to use an external RTC.

    • @giannidellaratta6141
      @giannidellaratta6141 9 หลายเดือนก่อน

      @@ControllersTech ok Thanks

  • @nitins7103
    @nitins7103 4 ปีที่แล้ว

    Thank you so much for the tutorial! Can i know how did u get to Ox32F2 in rtc backup register

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      I saw it in the example by ST.
      Anyway you can write any other value also, it doesn't matter what you write. But remember that you need to read the same value that you write.
      It's only used to prevent the rewriting of time and date if the mcu resets.

    • @nitins7103
      @nitins7103 4 ปีที่แล้ว

      @@ControllersTech Thanks for being really kind to answer. Much appreciated 🎉🎉🎉🎊

  • @Cesar-dt9nl
    @Cesar-dt9nl 4 ปีที่แล้ว

    Do you think is possible to show temperature too with the internal sensor?

  • @misterjacqwelll
    @misterjacqwelll 3 ปีที่แล้ว

    The Alarm dont work for me :S i got the F401RE there are something different to do?

  • @t1ltmare
    @t1ltmare 4 หลายเดือนก่อน

    Sir I got the code working but after a few changes of set_time and set_date the LCD refused to change the time and data and then LCD just showed nothing even after reconnect the board. How can I fix that?

    • @t1ltmare
      @t1ltmare 4 หลายเดือนก่อน

      LCD show my text if I send it before the while(1) loop, but it shows nothing that sends to it from the loop

  • @024muhamadfauzirochmatullo2
    @024muhamadfauzirochmatullo2 4 ปีที่แล้ว

    thank you for this video, can i make gTime in algorithm? i want to make every 12 PM to 17.00 PM there is variable that will be change.. how do we write in keil u vision?

  • @sumitbisht9658
    @sumitbisht9658 2 ปีที่แล้ว

    thanks for STM32 series , I have a problem when i pressed reset button time saved,and when i plug removed ,time didn't save.

    • @ControllersTech
      @ControllersTech  2 ปีที่แล้ว

      You need to connect a battery (to vbat pin) to keep the time..

  • @masterzerox2009
    @masterzerox2009 4 ปีที่แล้ว

    Excellent video, I'm using the STM32F103C8T6, I runs perfect, but the backup register 0x32F2 doesn't function, what backup register should I use?

  • @fernandocatalani8295
    @fernandocatalani8295 2 ปีที่แล้ว

    How do i make to not lost values when i reset the uC?

    • @fernandocatalani8295
      @fernandocatalani8295 2 ปีที่แล้ว

      I mean. When the power off...

    • @ControllersTech
      @ControllersTech  2 ปีที่แล้ว +1

      Connect the battery voltage to VBAT pin of the mcu.

    • @fernandocatalani8295
      @fernandocatalani8295 2 ปีที่แล้ว

      @@ControllersTech I've check the code and compare with your lesson. I was made a mistake in my code. The lesson guide to the solucion! Thank you for share the knowledge with us! Has been help me a lot!!!!

  • @saikrishnakaruturi2958
    @saikrishnakaruturi2958 ปีที่แล้ว

    Hi sir, I just write the code for alarm and am not using any LCD to display the string. I just toggled the LED to indicate the alarm. But unfortunately the LED is not toggled even the callback function is used. Could you please explain me why it is happening?

  • @arturoreyes2925
    @arturoreyes2925 4 ปีที่แล้ว

    Is there any possibility to hold time adding backup battery on Vbat pin? If so, is there some aditional software setup or something? I would like RTC to keep running even when main power supply is off

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      Yes you can connect the vbat to hold the time. Just make sure you use the backup register to check if the time is already set or not.

    • @arturoreyes2925
      @arturoreyes2925 4 ปีที่แล้ว +1

      @@ControllersTech Yes, I did. But every time I power off the controller, the RTC stops running and stands there until I power it on again. I want it to keep running even when main power supply is off. Is there a easy way to do so?

  • @fvgm
    @fvgm 3 ปีที่แล้ว

    Hi, it works very well with my F407VET6 .

  • @onurolce
    @onurolce 5 ปีที่แล้ว +1

    It restores TIME from registers but ,t doesn't restore DATE from registers. I made a search for solution in forums but there is no healthy solution for every scenario. Do you have a perfect solution or the best idea is using a DS1307 in real projects ?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      In actual projects, it's better if you go for ds3231 or 1307 rtc modules.

    • @onurolce
      @onurolce 5 ปีที่แล้ว

      @@ControllersTech Yes it seems so. I've found a DS1307 library and made tests but it doesn't work correct. I think it's better to start from basic level of I2C in STM32 and write our own library for DS1307, is it better right ?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      Yes it's always better to write your own library. Ds1307 is pretty simple thing to interface. Just take a look at it's datasheet.
      And regarding STM32, if you want to read the data from some particular register of ds1307, use the function hal i2c mem read. It works really well.

    • @onurolce
      @onurolce 5 ปีที่แล้ว

      @@ControllersTech Now I am looking your I2C videos about how it is working in STM. Then I'll follow your advices.

    • @onurolce
      @onurolce 5 ปีที่แล้ว

      @@ControllersTech Hi, first I wrote own code for Arduino and made it work then moved STM32CubeIDE and made pinout adjustments, I2C parameters but it did not work. After trying 6 hours I saw that DS1307 doesn't work 3.3V :) So supply my STM32F103C8T6 BluePill board in 5V pin and now it is working but I want to work with 3.3V system. So the best solution looks changing to DS3231, what do you advice ?

  • @hjia9721
    @hjia9721 7 หลายเดือนก่อน

    thank you for your video but it doesn't work on STM32F429ZIT6.. i want to know why ... why it doesn't work on lcd .. rtc alarm interrupt work well with usart and led..

    • @ControllersTech
      @ControllersTech  7 หลายเดือนก่อน

      The problem might be with the interfacing of LCD.
      First make sure the LCad is working. Then combine it with the RTC.

    • @hjia9721
      @hjia9721 7 หลายเดือนก่อน

      @@ControllersTech thank you for your reply. To explain my problem situation in more detail, I successed rtc clock on I2C LCD, but alarm interrupt still doesn't work. RTC alarm interrupt work on USART, LED toggle, but not work on LCD.
      if you don't mind, could you help me on email? I really want to complete this task(RTC alarm interrupt on I2C LCD), but I still haven't solved it even if I search for chatGPT,Google and TH-cam.
      ++Oh I DID IT haha no need to learn on email thank you again !

  • @Денис-з5е7ъ
    @Денис-з5е7ъ 6 ปีที่แล้ว

    THX,could you show how to adapt arduino librarys for stm32.Thanks again.

  • @bruryuyu
    @bruryuyu 5 ปีที่แล้ว

    If I put a battery on Vb pin? When I turn off it returns to the time on my init code?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      Do this.
      First set up the clock and flash the code.
      Than soon comment the setting up the time and date part and flash that code.
      This shall do the trick

  • @iqbalhaziq9529
    @iqbalhaziq9529 2 ปีที่แล้ว

    hye bro, where can i get i2c-lcd.c file?

  • @RixtronixLAB
    @RixtronixLAB 5 ปีที่แล้ว +1

    How can I save the clock, everytime I turn it off it returns to the time on my init code ??
    thanks

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว +1

      you can't store the data after the power is off because this is internal RTC and no separate power to the RTC. For that purpose, you can use a RTC module ds1307.

  • @jakubstejskal6806
    @jakubstejskal6806 5 ปีที่แล้ว

    Hello, I can't get my RTC working properly. There is no option for alarm in CubeMx on STM32F103 board, never mind. But my clock running about 3 minutes per second on same setup. Any idea?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      This video is quite old. I'll recheck things with F103 and get back..

    • @jakubstejskal6806
      @jakubstejskal6806 5 ปีที่แล้ว

      ​@@ControllersTech Thank you. Appreciate that. I have played with some settings and find out that AsynchPrediv equaled 23000 makes RTC work just fine (+- 1 second issue per minute i would say). But I cannot find any calculation or explanation of that parameter. Auto prediv 1 sec option makes RTC 1.5 slower compare to real. I am using LSE 32KHz, HSE 8MHz, HLCK 72MHz clock setup.

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      If you are feeding LSE 32.768 KHz to the RTC than async pre div of 127 and sync pre div of 255 will give the 1 Hz frequency..
      Use LSI 32 KHz than 127 and 249..

    • @jakubstejskal6806
      @jakubstejskal6806 5 ปีที่แล้ว

      @@ControllersTech True, understand that, but not same for f103 board. There is no synchPrediv option, in datasheet its not mentioned and Asynchprediv can be in range 0x00-0xFFFFF. Manual um1850, page 409. Maybe it can be set to registers directly but that is not my cup of tea.

    • @LuisReyes-zg7mq
      @LuisReyes-zg7mq 4 ปีที่แล้ว

      I Jakub, did you make it works? I mean, use BluePill with internal RTC

  • @LuisReyes-zg7mq
    @LuisReyes-zg7mq 4 ปีที่แล้ว

    Could you make a video for BluePill internal RTC? It would help a loy

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      RTC in BluePill is messed up. Half the features don't work. Better by a module like DS3231

    • @caffeinatedinsanity2324
      @caffeinatedinsanity2324 4 ปีที่แล้ว

      Thing is that it doesn't have a hardware calendar, so you'll have to make a software one. It acts more like a real time counter

  • @ravisoni2228
    @ravisoni2228 5 ปีที่แล้ว

    sir i want ro know how to use rtc wakeup alarm of 2sec to wakeup from stop mode? plz help...

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      What you want to wake up ?
      Just use alarm and than write some code when the alarm is triggered..

  • @MO_Ventures710
    @MO_Ventures710 3 ปีที่แล้ว

    Hi. I configured the RTC using backup register 1. Now the issue is when i try to assign new time and date, i also have to change the value in backup register, other wise it still have the old time and date. Lets say in future some user want to set his own time and date but he does not have access to change value in back up register to set his own time.So how can this be achieved without changing backup register.

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      You can write a function such that after setting the time, it will also change the backup register value.
      Like counter will increment each time the user sets the time, and this counter value will be set as a backup register value..

  • @pusatberk4193
    @pusatberk4193 6 ปีที่แล้ว +1

    Thank you,great video and website

  • @atefbenattia913
    @atefbenattia913 5 ปีที่แล้ว

    Hello, can I use stm32f407vg? and what would it change?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      I don't think anything will change at all you can try though

  • @bhakara4436
    @bhakara4436 ปีที่แล้ว

    for me the time is running fine even after reset but the date is changing ...how can i solve this??

    • @ControllersTech
      @ControllersTech  ปีที่แล้ว

      F103 ?

    • @bhakara4436
      @bhakara4436 ปีที่แล้ว

      yes
      @@ControllersTech

    • @bhakara4436
      @bhakara4436 ปีที่แล้ว

      what to do?

    • @ControllersTech
      @ControllersTech  ปีที่แล้ว

      Its a bug in f103 I guess. I had the same issue but couldn’t figure it out. I saw it being mentioned in some ST community but there is no solution.

    • @bhakara4436
      @bhakara4436 ปีที่แล้ว

      any alternative for this
      @@ControllersTech

  • @hussainkheti6096
    @hussainkheti6096 5 ปีที่แล้ว

    when i restart controller its not give update time its start from manually coded time
    so can we save time on rtc when controller goes to power off ?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      you can't store the data after the power is off because this is internal RTC and no separate power to the RTC. For that purpose, you can use a RTC module ds1307.

    • @hussainkheti6096
      @hussainkheti6096 5 ปีที่แล้ว

      @@ControllersTech really i am your big fan bcoz i like your instance replay.you have code for ds3231 rtc module ?

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว +1

      No i don't have the code at the moment but I'll try to publish it soon

  • @toanmai2371
    @toanmai2371 3 ปีที่แล้ว

    how to
    connecting LCD 16x2 with STM32 ?

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      I have updated the description. You can check now..

  • @smyrtin
    @smyrtin 3 ปีที่แล้ว

    Tell me where i can send beer for this tutorial! Big thanks !

  • @ilayarajamurugan9168
    @ilayarajamurugan9168 4 ปีที่แล้ว

    if config external oscillator RTC NOT WOKING PLZ HELP me

    • @ControllersTech
      @ControllersTech  4 ปีที่แล้ว

      Which controller and what's the error

    • @ilayarajamurugan9168
      @ilayarajamurugan9168 4 ปีที่แล้ว

      @@ControllersTech im using STM32H750VB when im config external osc it shows 00 only. Its not working

  • @bayuyutub5206
    @bayuyutub5206 2 ปีที่แล้ว

    Hy..
    Can you share code.
    How to get timestamp.
    Thank's

  • @임동현-o2m
    @임동현-o2m 5 ปีที่แล้ว

    Hell, Is this using ds3231?

  • @nandoperu100
    @nandoperu100 5 ปีที่แล้ว

    Hi Thanks for share your video !!
    I make a Code for RTC with Keil & True Studio Software but I have a Problem because after reset or power off the Micro-controller the valor for date is lost , showing in the display 01-01-200. For testing I used the chip board STM32F103C8 ( Bluepill) .Let me know if you have some idea for resolve this issue. If you prefer I can send to you the code.
    For your information the values for "Time " keep running without problem.

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว +1

      Internal RTC won't keep the time. Because one you power off the controller, there is no means of power to the RTC. You have to use the ds1307 rtc module, if you want to keep the time

  • @artedesing
    @artedesing 6 ปีที่แล้ว

    Hello Friend won another subscriber, I could not do this tutorial with my stm32f767zi card,

  • @elmir_rr
    @elmir_rr 2 ปีที่แล้ว

    you are great.

  • @baonguyenthe5970
    @baonguyenthe5970 4 ปีที่แล้ว

    Thank you very much

  • @srinuk1536
    @srinuk1536 5 ปีที่แล้ว

    #ControllersTech do videos with explaination,it will help for us.

    • @ControllersTech
      @ControllersTech  5 ปีที่แล้ว

      That was old video man. I try to explain as much as i can in my new videos..

  • @nsanandkumarak
    @nsanandkumarak 3 ปีที่แล้ว

    Hi ,
    Thanks for the video..
    Sir, can you make a video on temperature drift compensation on RTC.
    Thanks in advance

  • @sachindeshpande1
    @sachindeshpande1 5 ปีที่แล้ว

    Sorry I don't watch videos without voice over. Thanks.

    • @jobaptist
      @jobaptist 4 ปีที่แล้ว

      you can then create your own stm32 chips by using your shit to create the silicon in your bathroom ....

    • @sachindeshpande1
      @sachindeshpande1 4 ปีที่แล้ว

      @@jobaptist you idiot.

  • @TK-wh6lf
    @TK-wh6lf 2 ปีที่แล้ว

    Where i can find cmsis ???

  • @Tom-si5bb
    @Tom-si5bb ปีที่แล้ว

    Hello sir I want to compare the hours with a variable to make certain things work or say for e.g. I want to turn of my system as the rtc struck 11 pm how should I do that? please help

    • @ControllersTech
      @ControllersTech  ปีที่แล้ว

      write a if condition and check for the hours and minutes and seconds. when the condition is met, put the device in sleep mode. Check the low power modes video for that.

    • @Tom-si5bb
      @Tom-si5bb ปีที่แล้ว

      @@ControllersTech Thanks for the help!
      If possible can you please share the link of the video you are referring to and also a small logic code that I can use....