我的一个项目中的 STM32 F407 的 RTC 遇到了一个奇怪的问题。
摘要:函数 HAL_RTC_GetTime(...) 仅更新输出值一次,然后保持相同的值,但如果我在此函数中设置断点,它会更新。
描述:我最近从 CubeIDE 1.8.0 更新到 CubeIDE 1.9.0。在我的一个项目中,我遇到了这些奇怪的问题,如上所述。在更新IDE之前一切正常。更新后会出现这些奇怪的问题。这可能是巧合,但两天前一切正常。
我做了什么来解决这个问题:
首先,我在调用链上设置了一些断点,最后在生成返回值的 HAL 函数中设置了一些断点。我发现,如果调试器停止程序的执行,则 RTC_TimeTypeDef 结构的成员会正确更新,但当删除制动点时,不会更新 RTC_TimeTypeDef 结构的成员。
我的第一个猜测是:好的,在更新到 CubeMX 6.5 / CubeIDE 1.9.0 尝试 1 期间驱动程序出了问题
:我从项目设置中删除了 RTC,编译了项目(没问题),将 RTC 添加到了项目中再次,以相同的行为。
尝试 2:我创建了所有代码的备份,删除了该项目,创建了新项目,恢复了我的代码,然后重试。得到相同的结果(头脑=爆炸)我没有想到这一点,因为 - 至少现在 - CubeMX 生成的所有文件都必须使用最新的驱动程序从头开始生成。
在调试器窗口中,我可以看到结构“RTC_TimeTypeDef”的成员“小时”、“分钟”、“秒”根本没有改变,而是 DayLightSaving 和 StoreOperation 随机变化,而 SubSeconds 似乎计数正确。
此外:RTC 计时器本身似乎工作正常,因为 hrtc->Instance->TR 似乎在计算秒数
对我来说,它看起来像是一些位掩码或其他东西被搞乱了,而不是移动将小时、分钟和秒放入 Structm 成员中,HAL_RTC_GetTime(...) 将这些值转换为 DayLightSaving 和 StoreOperation。
有谁知道这里发生了什么事吗?特别是为什么它在设置断点时有效,但在其他情况下无效?任何提示,我将如何追踪这一点,我们将不胜感激。
我的解决方法很可能是直接使用 hrtc->Instance->TR 中的值并编写自己的转换。但我真的很想了解这里出了什么问题。
谢谢你并致以最诚挚的问候,
克里斯
I have a strange issue with the RTC of an STM32 F407 in one of my projects.
Abstract: The function HAL_RTC_GetTime(...) updates the output value only once, then remains at the same valule, but it updates if I set a breakpoint in this function.
Description: I have recently updated from CubeIDE 1.8.0 to CubeIDE 1.9.0. At one of my projects I have these strange issues, described above. Before the update of the IDE all worked fine. After the Update these strange issues occur. This might be a coincidence, but 2 days ago all worked fine.
What have I done to resolve this issue:
first of all, I set some breakpoints along the call chain and finally in the HAL function, where the return value is generated. I found out this way, that the members of the RTC_TimeTypeDef struct are updated correctly if the debugger stops the execution of the programm, but is NOT updated, when the brakpoint is removed.
My first guess was: ok, something went wrong with the drivers during the Update to CubeMX 6.5 / CubeIDE 1.9.0
Attempt 1: I removed the RTC from the Project Setup, compliled the Project (was OK), added the RTC to the Project again, with the same behaviour.
Attempt 2: I created a backup of all my code, deleted the project, created it new, restored my code and tried again. With the same result (mind = blown) I did not expect this, because - at least now - all files generated by CubeMX had to be generated new from scratch with the latest drivers.
In the debugger window I can see that the members Hours, Minutes, Seconds of the Struct "RTC_TimeTypeDef" do not change at all, instead DayLightSaving and StoreOperation are changing randomly, while SubSeconds seem to count correctly.
Furthermore: The RTC Timer itself seems to work correctly as hrtc->Instance->TR seems to count the seconds
For me it looks like some bitmasks or whatever are messed up and instead of shifting the Hours, Minutes and Seconds into the members of the Structm, HAL_RTC_GetTime(...) shifts these values into DayLightSaving and StoreOperation.
Has anyone an idea, what's going on here? Especially why it works when a breakpoint is set, but otherwise not? Any hint, how I could track this down is appreciated.
My workaround will most probably be, that I use the value from hrtc->Instance->TR directly and write my own conversion. But I'd really like to understand whats going wrong here.
Thank you and best regards,
Chris
发布评论
评论(1)
解决了!
诀窍是:您必须在读取 STM32F40x 上的时间后读取日期!
请参阅:https://community.st.com/s/question/0D73W000001Nvn5SAC
显然,CubeIDE 中的“Live Expression”探针也会触发“ReadDate()”函数。恕我直言,这就是为什么当设置对该变量的探测时 RTC 工作正常,但在其他情况下则不然。
Solved!
The trick is: you have to read the Date after reading the time on an STM32F40x!
see: https://community.st.com/s/question/0D73W000001Nvn5SAC
Obviously the "Live Expression" probe in the CubeIDE also triggers the "ReadDate()" function. This is IMHO the reason, why the RTC was working fine, when a probe on that variable is set, but otherwise not.