Closed northskysl closed 3 years ago
Github doesn't let me comment on unchanged lines, but I think this should be changed as well:
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
to
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
Need to test with LSI OFF but I would assume it is ok to turn it off too! It works with both LSI and LSE active though, at least in my testing.
Did a quick test with RCC_LSI_OFF. Seems to work fine! Clock runs and a game runs.
There is a quite annoying migration issue here.
If I go from the main branch to this directly, from a running target, HAL_RCC_OscConfig(&RCC_OscInitStruct)
will return an error. However, if I cold boot, it will resolve itself. Alternatively it works if I set RCC_OscInitStruct.LSIState = RCC_LSI_ON;
.
This is normally not a problem if you have an open unit and can power cycle easily, but I think many have made mods where they can keep the unit closed.
Not sure what the best way to proceed here, maybe setting RCC_OscInitStruct.LSIState = RCC_LSI_ON;
. I am not entirely sure what that means though, if that means that both LSI and LSE are running but that LSE is actually being used for time keeping.
I did run with both on and did not see issues from software perspective. It does mean that LSI is also on and that could have a negative impact on the power consumption of the device. How big of an impact, I do not know, but it does consume some extra power to have both LSI and LSE on at the same time.
Ideally we should measure with a µA meter as it may impact standby performance. I don't think it'll be that bad in any case, so let's just set RCC_LSI_ON for now.
Added a commit to restore the LSI bits
Here is an implementation of the STM32 RTC Hardware Support for the retro-go Game and Watch fork. The time can be viewed when pressing the "TIME" button on the main retro-go menu and by selecting Time or Date the aforementioned can be adjusted.