Good day
I would like to get the current time since the standard Epoch (00:00 01-01-1970) on my RT1170-EVK.
In other words, I want to have the functionality of the time() function from time.h on my board.
This function just returns zero, so I tried other avenues (like the SNVS_HP & SNVS_LP drivers), but nothing could give me the CURRENT time from the Real-Time Clock.
With the SNVS drivers, I can only set a time and calculate differences in time.
Kind regards
已解决! 转到解答。
For any other newbies with a similar question:
I realised the solution is to just set the time to the current time using the SNVS_HP/LP driver, as in the example evkmimxrt1170_snvs_lp_srtc_cm4.
As long as the processor is powered, this will give you the 'current' time.
Most final implementations have a small battery to power the LP registers to keep the RTC value ticking.
Kind regards
@D_TTSA your evkmimxrt1170_snvs_lp_srtc_cm4 example works well on my devices, but when I merge your code into my project get nothing
Hi @Suijunqiang
I need more information to be able to help you.
Hi, @D_TTSA
Thanks for your comments, and my answer as below in green.
Thanks & Best Regards
Sui
Hi @Suijunqiang
I need more information to be able to help you.
>>>I am using the example of "evkmimxrt1170_sd_jpeg_cm7" for the board of MIMXRT1170-EVK, and try to merge all your code as well as drivers(I try merge every thing), into the example.
By the way, the two projects work well independent.
>>>when PRINTF("Current datetime: %04hd-%02hd-%02hd %02hd:%02hd:%02hd\r\n", rtcDate.year, rtcDate.month, rtcDate.day,
rtcDate.hour, rtcDate.minute, rtcDate.second);
we get "Current datetime: hd-hd-hd hd:hd:hd"
Hi @Suijunqiang
Well, when you imported the code and drivers, did you remember to import the clock configuration settings too?
For example, I looked at the snvs_hp_rtc_cm7 SDK example, and it shows a dependence on kCLOCK_SnvsHp.
If this clock is not configured (with the correct settings) in your merged project, then this could cause your problem, I think.
Let me know,
D_TTSA
@D_TTSA
How to set "kCLOCK_SnvsHp" dependence in my project?
I have merged all your MACROs in to my code, also I searched "kCLOCK_SnvsHp" in your code.
sui@CNSHA1JTS517LP:/mnt/c/Users/3502594/src/nxp/evkmimxrt1170_snvs_hp_rtc_cm7$ find . -type f | xargs grep -i "kCLOCK_SnvsHp"
Binary file ./Debug/evkmimxrt1170_snvs_hp_rtc_cm7.axf matches
Binary file ./Debug/source/snvs_hp_rtc.o matches
grep: ./evkmimxrt1170_snvs_hp_rtc_cm7: No such file or directory
grep: LinkServer: No such file or directory
grep: Debug.launch: No such file or directory
./source/snvs_hp_rtc.c:#define kCLOCK_SnvsHp0 kCLOCK_SnvsHp
Hi @Suijunqiang
I don't know why you are referring to the CM4 example as "my" code - it is NXP's code.
I have looked into it again, and yes, you are correct - it's rather strange that the SDK example defines this macro, but does not use it (and kCLOCK_SnvsHp is not defined, but it doesn't give an error?).
Anyway, since you have copied the source code and drivers across from the SDK example into your code, there are two potential causes of the difference between the example project and your project. They are:
I see that the SDK examples do not have a .mex file by default. However, I think that it is most likely a pin problem, since, as mentioned above, the RTC does not seem to be dependent on a specific clock.
Try to find all symbol, clock and pin differences between the two project. I'm quite certain that you will find your problem there.
D_TTSA
For any other newbies with a similar question:
I realised the solution is to just set the time to the current time using the SNVS_HP/LP driver, as in the example evkmimxrt1170_snvs_lp_srtc_cm4.
As long as the processor is powered, this will give you the 'current' time.
Most final implementations have a small battery to power the LP registers to keep the RTC value ticking.
Kind regards