The RTC driver topic

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: The RTC driver topic

Postby Giovanni » Sat Nov 01, 2014 3:37 pm

In my opinion the driver should not depend on the library or we would be back to the previous situation which is exactly what I wanted to avoid, the library should be optional.

The realtime counter clock is the system clock.

Giovanni

User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Location: Minsk, Belarus
Been thanked: 7 times

Re: The RTC driver topic

Postby barthess » Sat Nov 01, 2014 4:46 pm

Next step performed.
Conversion code moved to rtc.c(h). Now HAL contains all needed functions.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: The RTC driver topic

Postby Giovanni » Sat Nov 01, 2014 5:13 pm

Much nicer this way I think, users will not have to search for extra files.

Giovanni

User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Location: Minsk, Belarus
Been thanked: 7 times

Re: The RTC driver topic

Postby barthess » Sat Nov 01, 2014 7:58 pm

Giovanni wrote:Much nicer this way

Agree.
I have fixed RTC testhal application for F4x.
Waking up on it works fine in opposite to F1x I still have no ideas why.

Michail
Posts: 28
Joined: Mon Aug 04, 2014 6:55 am

Re: The RTC driver topic

Postby Michail » Sun Dec 21, 2014 5:06 pm

Hello Barthess, hi Giovanni!

Think I've stumbled upon a bug in the RTC driver in current trunk on STM32F100C8.

In halInit() function hal_lld_init() calls before rtcInit().
hal_lld_init() calls hal_lld_backup_domain_init(), it calls rtc_lld_set_prescaler(), it calls rtc_acquire_access() and at last it calls rtc_wait_write_completed() :)
Call stack for my code is:

Code: Select all

8 rtc_wait_write_completed() rtc_lld.c:74 0x080059aa   
7 rtc_acquire_access() rtc_lld.c:87 0x080059d8   
6 rtc_lld_set_prescaler() rtc_lld.c:191 0x08005ad0   
5 hal_lld_backup_domain_init() hal_lld.c:76 0x08001992   
4 hal_lld_init() hal_lld.c:109 0x080019f4   
3 halInit() hal.c:66 0x08005b6c   

and in rtc_wait_write_completed() in os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c we can see:

Code: Select all

static void rtc_wait_write_completed(void) {
  while ((RTCD1.rtc->CRL & RTC_CRL_RTOFF) == 0)
    ;
}

But RTCD1 was not initialised yet! RTCD1.rtc points to NULL and my program hangs here.

Code: Select all

"RTCD1"   {...}   
   rtc   0x00000000   
   callback   0x00000000   

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: The RTC driver topic

Postby Giovanni » Sun Dec 21, 2014 5:11 pm

Hi,

Thanks for finding, tomorrow I will fix this.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: The RTC driver topic

Postby Giovanni » Mon Dec 22, 2014 10:21 am

I just committed a fix, could you verify functionality? I lack HW for this.

Giovanni

Michail
Posts: 28
Joined: Mon Aug 04, 2014 6:55 am

Re: The RTC driver topic

Postby Michail » Mon Dec 22, 2014 12:10 pm

Yes, now everything works fine!

Thank you!

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: The RTC driver topic

Postby steved » Mon Dec 29, 2014 8:42 pm

Just looked at the latest change to STM32/lld/rtc2/rtc_lld.c; calls to rtc_enter_init(); and rtc_exit_init(); have been added round the calendar initialisation. These calls are already present earlier and later in the code - should they have been deleted?

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: The RTC driver topic

Postby Giovanni » Mon Dec 29, 2014 8:49 pm

It is possible, probably I misunderstood the requested change there, I will look into it again tomorrow.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 58 guests