2017-10-09 04:52 AM
@
Hi,
I did my project in cubemx with STM32F405.
But unfortunately i forgot to add/initialize rtc in cubemx.
Now i want to add rtc in my project.
And i don't know how to add it (because my code size is too much heavy and i dont want to do rework in cubemx).
Can you please tell me how can i do this without cubemx?
Thank you.
#
2017-10-09 05:32 AM
Could you create a donor project and use WinMerge to pull the incremental additions? Could you review the RTC examples under the Cube directories and merge the required code?
2017-10-09 11:08 PM
I'm sorry but i don't know WinMerge Concept?
I will create one more project in cubemx with rtc initialization and whatever the rtc code (initialization and other) i will add in my existing project.
Is it possible / is a right way to do this?
Thank you.
2017-10-12 02:49 AM
Problem not solved.
st.mcu
please help.
2017-10-12 07:03 AM
Perhaps you should study diff and merge concepts so you can apply then here.
You can manually cut and paste code if that's a more comfortable method
2017-10-12 07:09 AM
,
,
Generate a project with STM32CubeMX application consisting of nothing but the RTC. , in the project settings, choose 'generate as separate .c/.h files' and add the rtc.h and rtc.c files to your project. , If you want to use alarms, add void RTC_Alarm_IRQHandler(void), to stm32f4xx_it.h. , Uncomment the RTC module from stm32f4xx_hal_conf.h. , Add ♯ include 'rtc.h' to main.c, and in main() add MX_RTC_Init(),
2017-10-12 10:50 PM
Thank you.
2017-10-13 03:29 AM
Now rtc initialized without any error and show some value.
while(HAL_RTC_GetTime(&hrtc,&sTime,RTC_FORMAT_BCD)!= HAL_OK)
while(HAL_RTC_GetDate(&hrtc,&sDate,RTC_FORMAT_BCD)!= HAL_OK)
sprintf(MyStr, '%d:%d:%d:%d - %d/%d/%d $',sTime.Hours,sTime.Minutes,sTime.Seconds,sTime.SubSeconds,sDate.Date,sDate.Month,sDate.Year); LCD_ShowString((32*6),0,MyStr,32);sTime.Minutes:-Increment one by one.
sTime.Seconds:Increment but in a wrong way.
for example increment like 1,2,3..and directly jumped to 10,11,12...
And one interesting thing is second overflow means gave values which are more than 60 (eg.60,61,63....)
how it is possible?
what is the issue?
Thank you.
2017-10-13 06:29 AM
You are using BCD, you need to use %02X not %d
Fifty nine seconds is 0x59
If you want binary numbers use the BIN mode.
2017-10-13 06:35 AM
uint8_t bcdToDec(uint8_t val) {
// Convert binary coded decimal to normal decimal numbers
return ( (val/16*10) + (val%16) );
}
�?�?�?�?