- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Suijunqiang
I need more information to be able to help you.
- What do you mean by "merge your code into my project"? Did you import the correct drivers?
- What do you mean by "get nothing"? What values are printed?
- Do you want to hold the value when your device is switched off, and restore the clock value after a reboot? If not, please describe your desired functionality.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- What do you mean by "merge your code into my project"? Did you import the correct drivers?
>>>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.
- What do you mean by "get nothing"? What values are printed?
>>>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"
- Do you want to hold the value when your device is switched off, and restore the clock value after a reboot? If not, please describe your desired functionality.
>>>No, at this moment we only need current time to verify how much time in different code operation;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Project properties -> C/C++ General -> Paths and Symbols -> Symbols
- The configuration file (.mex) that defines the pinmux and clock routing
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ohaaaaaaaaa.....
Dear, D_TTSA,
It works fine now, the issue cause by the function of PRINTF formate .
Thanks & Best Regards
Sui
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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