STM32F4 Discovery board - Keil 5 IDE with CubeMX: Tutorial 20 - Real Time Clock (RTC)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

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

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

    Did this one, did notice that the sTime, sDate, and sAlarm were local in static void MX_RTC_Init(void). You moved them as global variables and I had to do the same so you can use them outside the function. If people want to change something and regenerate the code they need to be aware the code generator will make those variables again giving you two definitions. It compiled fine but don't like the same variable in a local function and as global. I made mine static, but just for people to be aware of it. Thanks for thee tutorials, these are really helpful. I'm using a nucleo-F767ZI and the tutorials are helpful.
    I'm looking to possibly take your LCD driver code and make a somewhat platform independent driver for using the 16x2 LCD on not only a STM but also a Renesas eval board. Just a thought right now but it would be cool to do.

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

      Hi mate,
      Agree!
      And please go ahead and play with the library.

    • @arifkhan-xs5nk
      @arifkhan-xs5nk 4 ปีที่แล้ว

      how can i use lcd and i2c to show the time and date . i tried but i can see only weird characters on the lcd

    • @alybadawy-personal7962
      @alybadawy-personal7962 2 หลายเดือนก่อน

      @@arifkhan-xs5nk One trick I learned to get around the generated code being different from what I want, is write my whole code in user_code_0 then put a nice `return;` after my code, so the function never reaches the generated code after that early return. may look weird but gets the job done!

  • @civilizeddiscussion697
    @civilizeddiscussion697 6 ปีที่แล้ว +7

    time and date initialization in cubemx fail because you set the year wrong, it must be 0-99. it is very helpful btw

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

      tory utama
      Hi Tory,
      Awesome! I will try that.

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

      I was going to say that, I observed in the video he wrote 2017, but it only allows 0-99. I did the same mistake as well.

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

      rwbazillion
      Well spotted .. you're right :)

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

    Thank you for your help sir.

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

    Hi Mohamed
    I'm using your LCD1602 library to write informations on LCD.
    I watched your video about RTC and I liked so much.
    Now i'm trying write the RTC variables like so date, month, year, hour, minute and second using your LCD1602 library.
    This informations are displayed on LCD, but the actualization this information don't occur.
    I'm using a STM32F4 Dicovery board that have a ST32F407VGT microcontroler. In this board the VBAT pin is connected to VDD 3.3V.
    Only to clarify, I'm using this "subvariables":
    sDate.Date for date
    sDate.Month for month
    sDate.Year for year
    sTime.Hours for hours
    sTime.Minutes for minute
    sTime.Seconds for second
    What I can do to solve this problem? Please, could you help me?
    I'm waiting your answer, thanks.

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

    RTC lagging 8sec for every 10 min, is there is any way to calibrate rtc for more accuracy

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

      Hi,
      Yes, I mentioned that if you use internal oscillator, it will not be accurate, need to use 32.768 KHz external LSE oscillator.
      The STM32 F4 Discovery boards does not come equipped with one, can put one yourself there is an SMD pad free for LSE. ot just use another STM board with an LSE. Thanks

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

    What is the lowest power mode you can put the stm32 in that keeps RTC on and it is possible to wake up the micro with external interrupt? if it is important it is for stm32L0 series. Thanks

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

      I think I figured it out, it is STOP state.

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

    Hi yaqoob please make a series of vedios on IOT protocols(http, MQTT, TCP/IP), and wifi and Bluetooth interfacing.
    Thanks

  • @fernando.liozzi.41878
    @fernando.liozzi.41878 4 ปีที่แล้ว

    Hello, is there any way to configure the RTCC when programming the STM32 ?, in compilers like MPLABX, we have the macros __TIME__ and __DATE__ that take the system time at compile time, and we can parsing to configure the rtcc. Thanks!

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

    Hello,
    I have tried to implement RTC code. However my RTC doen't count. When a try to catch the RTC time he returns the same value every time

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

      Amandio Real I also have the same problem. Is it resolved? Please let me know how you resolved it

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

    hii.
    i tried this but my time doesn't increments even after the subsecond are incrementing..
    can u please help.?

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

      Madhuri Trivedia
      Hi, might be just a little thing you forgot.. Go over the code again, I'm sure u will figure it out.

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

      hi,
      we checked and followed u step by step..still isn't working..

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

      Are you using the same board?

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

      yes stm32f4 discovery board

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

      the clock configurations are also same...

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

    Excellent video thank u.can I use this in shut down mode n generate alarm every 5 minute n wakeup.do u have any suggestions.

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

      Interesting one!
      I have not tried this before. But I came across it in the reference manual on page 787, there it explains how to use 'Periodic Auto-Wakeup'.

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

    I found the problem. I must call GetTime and then GetDate.

  • @aliefiandiojulianto2712
    @aliefiandiojulianto2712 4 ปีที่แล้ว +2

    thanks bro

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

    dear sir, why don't we need to call HAL_NVIC_EnableIRQ for SysTick as we do for RTC timer? Is it activated by default, or is configured somewhere else in the program? please advise. thanks.

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

      There so many things done in background by CubeMX that you will miss if you don't train from scratch on STM32 without CubeMX.

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

    Cube mx set the timeand date for me. but STM studio doesnt show the sDate and sTime variables. Can someone help me pls? i followed the steps. thank you

  • @BenBilesBB-box
    @BenBilesBB-box 5 ปีที่แล้ว +1

    especially like the non cube part of the video! thanks!

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

    Good one bruv.. subscribed to ur channel.. I have a case here . Can u explain what can be done.. I need rtc to wake up at certain time and usher GSM and GPS module (which is in deep sleep) for sending data and after that it again need to go to sleep.. like @9am module should power on and send data and again goes to sleep.. repeat .

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

      Hi Kumar,
      You can use Alarm function to trigger your devices, on the specified time. hope this helps

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

    I take this video as reference to understand the concept of RTC but I wanted to know to use RTC to time stamp data...Could you guide me for this

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

      Hi,
      Is it just reading the time and date that correspond to acquiring a sample of data?
      It is simple enough, you just need to schedule a Time and Data reading at the acquisition instance, then can do all the fun bits (e.g. creating a comma separated values CSV file where time is one of the columns). Hope this helps. Good luck

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

    mohamed where is the code why why !!

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

    Using a "virgin" build I get fatal errors "os_tick.h: No such file or directory" :(

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

    Excellent buddy! Thanks

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

    RTC gets re-initialized to old value when System Reset occurs. Have tried alternate scheme on this? Resetting the RTC: The calendar shadow registers (RTC_SSR, RTC_TR and RTC_DR) and some bits of the RTC status register (RTC_ISR) are reset to their default values by all available system reset sources. On the contrary, the following registers are resetted to their default values by a backup domain reset and are not affected by a system reset: the RTC current calendar registers, the RTC control register (RTC_CR), the prescaler register (RTC_PRER), the RTC calibration registers (RTC_CALIBR or RTC_CALR), the RTC shift register (RTC_SHIFTR), the RTC timestamp registers (RTC_TSSSR, RTC_TSTR and RTC_TSDR), the RTC tamper and alternate function configuration register (RTC_TAFCR), the RTC backup registers (RTC_BKPxR), the wakeup timer register (RTC_WUTR), the Alarm A and Alarm B registers RTC_ALRMASSR / RTC_ALRMAR and RTC_ALRMBSSR/RTC_ALRMBR).

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

    Hello Mohamed,
    How can I show time on lcd screen instead of stmstudio?
    I have already seen your video about the lcd1602 and I have the library you shared with us.
    please respond me soon.

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

    Thank you

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

    can you explain generally what is the difference if i use external clock such as ds1302? and can i add coin cel battery with internal clock? i need it for my data logger project, or you have any better option?

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

      tory utama
      Hi tory,
      If you wanna use STM32 RTC, you need to have an external Low Speed oscillator, some STM boards comes with that built in, some don't like the STM32F4 DISCOVERY.
      For RTC battery pin on stm32, read this article:
      www.eletel.p.lodz.pl/mipsa/index.php/en/projects/151-stm32f4-discovery-rtc-hack

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

      MYaqoobEmbedded i use Stm32f4discovery. Do you have any tips for my data logger project? Note that it is my first time doing microcontroller project and my teacher force me to use stm32 instead of arduino. I will use can bus too for communication with other projects.

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

      @@mutexembedded2206In my opinion, I would say that the internal RTC is more for advanced users, because a setting bug can lead to a complete freezing of the microcontroller (and it doesn't have to be right away, but maybe with a dead battery) and only help to full erase the chip and reupload the firmware. For less skilled geeks, an external circuit is a better and safer choice.

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

      @@Filipx87page I agree with what you mentioned, it is true that ST could have done way better job, but you can still do a lot with the built-in RTC.

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

    Hi friend, I would like to know how to program using the standard library for STM32, rather than the HALL library?

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

    Ok i have battery but when CPU restart . Rtc init () again.
    Android s.time set again value. İ font want this.

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

    hi my friends. ı did that its work but when restart cpu , rtc start begin time.do u know how can ı do it.

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

      İsmail Erol Coder
      Hi,
      Need to connect a battery through Vbat pin to keep rtc running

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

      No no I mean, I'm using stm32f407vet6 .
      This card has a internal rtc. When I set date and time it's working good with battery .
      But when I reset CPU manual. And then I saw time is back to set again.
      Hope I explain to you my friend. :)

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

      @@acocrw5808
      Hi,
      I see what you mean, you need to set time and date once, delete set Time/Date code and re-upload code. All while battery is connected.
      Then just keep reading RTC.

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

    Thank you so much!

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

    if i'm choose external crystal my controller not show the time plz help me

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

    FYI Synch prediv should be set to 249 for 32k LSI

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

    Mohammed keep going my brother. You are very helpful. Thank you very much!

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

    hi bro. Thank you so much.

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

    very useful