- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
I'm using Modustoolbox to run the example AnyCloud_MQTT_Client with AWS on the board CY8CPROTO-062-4343W.
I modified the example just to update the RTC to be able to add a timestamp to the MQTT json messages that are sent to the cloud.
If I update the RTC before the MQTT connection is done, then, once the app connects to the MQTT broker the RTC goes to EPOCH 1970-01-01 00:00:00. Dunno if this means that the RTC is reseted.
If I wait until the app connects to MQTT and then I update the RTC then it works fine and the RTC keeps providing updated time.
Any idea why this is happening? or what am I missing here?
I'm using the code snippes in [1] to update the RTC
[1] https://infineon.github.io/psoc6hal/html/group__group__hal__rtc.html
Solved! Go to Solution.
- Labels:
-
PSoC 6 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @mvpablo ,
Some developments on this. Since the RTC is being used internally, you need to set the instance right after initialization i.e. cy_set_rtc_instance must be called right aftercyhal_rtc_init and this should fix the issue.
This has been documented as part of the Time Support Details section in the clib-support library, you can find its readme here.
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @mvpablo ,
I'm able to reproduce this error. I checked why this might be happening. Basically, when mqtt_connect is called, it tries to establish a secure TLS connection with the broker. For this, the RTC is being used internally and this is why your values gets reset. You can dig through to find the sequence, but basically, there is this API get_current_time() in the secure_sockets library (see cy_tls.c) which calls the time() function which is part of clib-support library (see cy_time.c) which uses RTC APIs which is causing this issue.
I have forwarded this issue to the software team for evaluation. Please update the RTC after the MQTT connection is done for now. I will let you know once the fix is available.
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @mvpablo ,
Some developments on this. Since the RTC is being used internally, you need to set the instance right after initialization i.e. cy_set_rtc_instance must be called right aftercyhal_rtc_init and this should fix the issue.
This has been documented as part of the Time Support Details section in the clib-support library, you can find its readme here.
Regards,
Dheeraj