Page 1 of 3

STM32F030 and RTC

Posted: Fri May 06, 2016 1:53 am
by dflogeras
Hi,

GCC-4.9.3, newlib-2.2.0, binutils-2.25, ChibiOS-3.0.5

I'm playing with a new chip, namely STM32F030. I'm interested in using its RTC to set an alarm and wake the device up after a snooze. I used the testhal/STM32F1xx/RTC program as a starting point and enabled the HAL_USE_RTC. When I try to compile, I get

Code: Select all

main.c:133:3: warning: implicit declaration of function ‘rtcSTM32GetSecMsec’ [-Wimplicit-function-declaration]
   rtcSTM32GetSecMsec(&RTCD1, &tv_sec, NULL);
   ^
main.c:133:31: error: ‘tv_sec’ undeclared (first use in this function)
   rtcSTM32GetSecMsec(&RTCD1, &tv_sec, NULL);
                               ^
main.c:133:31: note: each undeclared identifier is reported only once for each function it appears in
main.c:134:12: error: ‘RTCAlarm’ has no member named ‘tv_sec’
   alarmspec.tv_sec = tv_sec + 20;


After looking in the specific rtc_lld.h, I see it is because STM32_HAS_PERIODIC_WAKEUPS is not defined in stm32_registry.h for this device. According to this the device's RTC does have periodic wakeup. I'm not sure how to fix this, help/advice is appreciated!

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 10:37 am
by RoccoMarco
I will take a look. It could be a bug.
Thanks. Ciao,
RM

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 1:16 pm
by dflogeras
Thanks Rocco! I'm happy to test patches if you do not have access to hardware.

Dave

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 1:18 pm
by RoccoMarco
Thanks a lot... In this case I have a STM32 Nucleo64-F030R8. I am porting the RTC demo to test the HAL.

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 1:34 pm
by RoccoMarco
So I am editing the DEMO. The biggest problems appears to be the missing of all the bit mask and structure related to Periodic Wakeup.

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 2:19 pm
by dflogeras
I notice that in os/ext/CMSIS/ST/stm32f030x8.h there are a couple fields missing from the RTC_* related registers. For instance RTC_CR does not include RTC_CR_WUTE and RTC_CR_WUTIE, but the data sheet indicates these fields are present in the f030x6/8/C devices as well as the f070x6/B devices.

I assume that these headers come directly from ST/ARM and not ChibiOS, is there a newer CMSIS available that includes these? I'm not sure where they come from, I have an ARM CMSIS package downloaded to get the DSP libraries but it does not include these files.

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 2:38 pm
by RoccoMarco
I assume that these headers come directly from ST/ARM and not ChibiOS, is there a newer CMSIS available that includes these? I'm not sure where they come from, I have an ARM CMSIS package downloaded to get the DSP libraries but it does not include these files.


Indeed these headers comes directly from ST. Even more the RTC struct misses RTC_WUTR! It is very strange. I have checked documentation more than once looking for a note saying that wakeup is not available on STM32F030xx (without success).

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 2:50 pm
by Giovanni
Header files are those released by ST in Cube MX, our policy is to not modify them.

I suggest to post about this in the ST forums and ask if it is an header error or if the feature is really missing in the device.

Giovanni

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 3:13 pm
by RoccoMarco
Giovanni wrote:Header files are those released by ST in Cube MX, our policy is to not modify them.
I suggest to post about this in the ST forums and ask if it is an header error or if the feature is really missing in the device.


I can confirm. Indeed, We can not know whether the error is in the CMSIS header or documentation. I will ask on the STM32 forum. Until that moment we will assume that RTC doen't have periodic wakeup.
Ciao,
RM

Re: STM32F030 and RTC

Posted: Fri May 06, 2016 4:04 pm
by dflogeras
Thanks Rocco,

In the meantime I downloaded the latest headers from ST, and while there are numerous changes from the one included with ChibiOS-3.0.5 (ST ver 2.0.1, versue 2.2.3) they didn't add the registers/bitmaps in question.

Out of curiousity, if the HW itself doesn't support the periodic wakeups, does the current RTC driver implementations operate in a diminished mode, or not at all?