2022-05-30 08:54 PM
Hello ,
I see from the stm32mpu wiki RTC is not available for CM4. I am porting one RTC project from F411 to CM4 .
Is there any alternate to this which i can use having same functionality?
Br,
D
2022-05-30 11:28 PM
HI @darla14 ,
RTC and associated event (interrupts, alarms, etc..) belongs to Linux, but you could read time and date from Cortex-M4 using HAL functions and adding "stm32mp1xx_hal_rtc.c" in your project.
e.g. something like this might work:
#include "stm32mp1xx_hal_rtc.h"
RTC_HandleTypeDef hrtc;
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
hrtc.Instance = RTC;
/* RTC clock enable */
__HAL_RCC_RTCAPB_CLK_ENABLE();
HAL_RTC_GetTime(&hrtc, &sTime ,RTC_FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &sDate ,RTC_FORMAT_BIN);
Note that RTC might become not accessible when Linux is in low power.
Depending on your usage, you might need some additional computation to adjust to Linux timezone as RTC is usually in UTC. See also https://wiki.st.com/stm32mpu/wiki/How_to_use_the_RTC for Linux information.
Regards.
2022-06-09 11:19 AM
in engineering mode I can see the rtc hours,minutes, seconds and sub-seconds increasing ...which is fine. but in production mode i am getting hard fault.
is it even possible to use the rtc in the production mode in M4? How?
if not what is the alternative to it on M4 side?
best
D
2022-06-09 11:29 PM
Hi,
Could you please precise in which function your get hardfault ?
Maybe, as you tried in engineering mode, you have probably added some additional RTC init to make it working. Did you ensure the init linked to RTC (except what I listed above) are conditioned by "IS_ENGINEERING_BOOT_MODE()" ?
Regards
2022-06-10 12:46 AM
Hello @PatrickF
I attach the call trace,
Its while getting the tick. Rest of the peripherals works well , if I comment this or run with this in engineering mode.
But as soon as I turn on the Production mode and debug this , I get this.
there is no change in the main code and it is as it is generated by CubeMX
if(IS_ENGINEERING_BOOT_MODE())
{
PeriphCommonClock_Config();
}
else
{
MX_IPCC_Init();
MX_OPENAMP_Init(RPMSG_REMOTE,NULL);
}
IS_ENGINEERING_BOOT_MODE is 0
Thanks in advance to look into this.
Best Regards,
D
2022-06-10 01:07 AM
Seems you are trying to init the RTC while it is already init by Linux when in production mode.
The code I have put should be enough to access RTC time/date.
The hardfault is likely coming from instruction before the GetTick, e.g. "SET_BIT(PWR->CR1..." which is not allowed in production mode (PWR is likely secured by Linux)
Regards,
Patrick