-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delay limited to frequencies over 1MHz #111
Comments
I don't think that adding a new API for low-power mode delays would be a good solution, as the current API is implementing standard APIs from the I think the most practical solution is to remove that assert and make sure the rest of the code is smart enough to handle low frequencies. I think it's fine to lose precision in that case, as long as that's clearly documented. |
First of all I need to say that I'm not enough of an embedded Rustacean to code it myself, in fact I might be getting it all wrong :) But this line:
that's integer division, right? The result will be u32, so if the frequency drops below 1MHz it will be just 0 ticks per microsecond, unless I'm getting it all wrong? |
Yes, I believe that's correct. That's why I said we need to make sure the code is smart enough to handle it, because the line you quoted certainly isn't :-) I think we need to store If we calculated let total_rvr = self.freq * us / 1_000_000; Then it should work for low frequencies. There's a danger of an overflow from the multiplication though. Not sure what the best way to handle that is. Maybe cast to I don't know. This requires some more thinking. |
Current implementation of delay asserts that the clock frequency is > 1_000_000 Hz, which limits its usage with MSI as clock source to Range4..Range6.
I understand that this is because otherwise we'd have less than 1 tick per microsecond, e.g. with Range0 at 65 kHz.
Would it make sense to add another method, e.g. LPDelay as in LowPower, with resolution expressed in ticks_per_ms and only DelayMs implemented?
The text was updated successfully, but these errors were encountered: