Page 20 of 23
Re: The RTC driver topic
Posted: Sat Nov 01, 2014 3:37 pm
by Giovanni
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
Re: The RTC driver topic
Posted: Sat Nov 01, 2014 4:46 pm
by barthess
Next step performed.
Conversion code moved to rtc.c(h). Now HAL contains all needed functions.
Re: The RTC driver topic
Posted: Sat Nov 01, 2014 5:13 pm
by Giovanni
Much nicer this way I think, users will not have to search for extra files.
Giovanni
Re: The RTC driver topic
Posted: Sat Nov 01, 2014 7:58 pm
by barthess
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.
Re: The RTC driver topic
Posted: Sun Dec 21, 2014 5:06 pm
by Michail
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
Re: The RTC driver topic
Posted: Sun Dec 21, 2014 5:11 pm
by Giovanni
Hi,
Thanks for finding, tomorrow I will fix this.
Giovanni
Re: The RTC driver topic
Posted: Mon Dec 22, 2014 10:21 am
by Giovanni
I just committed a fix, could you verify functionality? I lack HW for this.
Giovanni
Re: The RTC driver topic
Posted: Mon Dec 22, 2014 12:10 pm
by Michail
Yes, now everything works fine!
Thank you!
Re: The RTC driver topic
Posted: Mon Dec 29, 2014 8:42 pm
by steved
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?
Re: The RTC driver topic
Posted: Mon Dec 29, 2014 8:49 pm
by Giovanni
It is possible, probably I misunderstood the requested change there, I will look into it again tomorrow.
Giovanni