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: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: The RTC driver topic

Post by Giovanni »

Fix committed, thanks.

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

Re: The RTC driver topic

Post by barthess »

Hi Giovanni
I want to change function prototype from

Code: Select all

void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
                                  struct tm *timp)

to

Code: Select all

void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
                                  struct tm *timp,
                                  uint32_t *tv_msec)

to be able to obtain fractional seconds part.
Is it possible in trunk?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: The RTC driver topic

Post by Giovanni »

Sure go ahead, just make sure both implementations work with the change.

Note that I wish to do a "preview" 3.0 release during the weekend.

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

Re: The RTC driver topic

Post by barthess »

What the second implementation you talking about? I want to improve just a single function
rtcConvertDateTimeToStructTm from RTC HAL realization.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: The RTC driver topic

Post by Giovanni »

I thought low level drivers were impacted, this is not the case.

Giovanni
User avatar
Chudik
Posts: 152
Joined: Fri Jan 16, 2015 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: The RTC driver topic

Post by Chudik »

Did I understand correctly that this driver does not initialize which clock should be used for the RTC?
STM32L1 family has internal 37kHz generator, I would like to is it instead of the External 32kHz clock
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: The RTC driver topic

Post by Giovanni »

Hi,

Clock settings are all in mcuconf.h in the clocks section.

Giovanni
User avatar
Chudik
Posts: 152
Joined: Fri Jan 16, 2015 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: The RTC driver topic

Post by Chudik »

Hmm... LSI in mcuconfig.h is enabled by default.
HAL_USE_RTC in halconf.h I set to TRUE

That means RTC should work and rtcInit() should pass, but it does not.
It stops in rtc_lld_init() at calling

Code: Select all

  /* If calendar not init yet. */
  if (!(RTC->ISR & RTC_ISR_INITS)){
    rtc_lld_enter_init();   // <----------- stops here
....
}


If I try to make a step over the function or into it, the system hangs.

What could be the problem?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: The RTC driver topic

Post by Giovanni »

Probably the oscillator is not starting at all, it is very critical, see application notes.

Giovanni
User avatar
Chudik
Posts: 152
Joined: Fri Jan 16, 2015 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: The RTC driver topic

Post by Chudik »

Found what was the problem.
in mcuconf.h by default set
#define STM32_RTCSEL STM32_RTCSEL_LSE
while by default we have
#define STM32_LSI_ENABLED TRUE
#define STM32_LSE_ENABLED FALSE

When I changed
#define STM32_RTCSEL STM32_RTCSEL_LSI
RTC initialization went successfully.

Found that after switching from 2.6.7 to 2.6.8, because it gave error that wrong setting used.
Probably would be useful to have

Code: Select all

#if (STM32_LSI_ENABLED)
   #define STM32_RTCSEL                        STM32_RTCSEL_LSI
#elif (STM32_LSE_ENABLED)
   #define STM32_RTCSEL                        STM32_RTCSEL_LSE
#endif
Post Reply