Skip to content
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

Fixed setting HardwareTimer interrupt priority #1062

Merged
merged 2 commits into from
May 13, 2020

Conversation

sjasonsmith
Copy link
Contributor

Summary

HardwareTimer interrupt priority is currently set in the constructor inside the call to HAL_TIM_Base_Init. Setting the priority using HardwareTimer::setInterruptPriority stored the priority, but it was only applied if the timer was re-initialized. This would be unlikely to ever occur for typical HardwareTimer users.

This change applies the interrupt priority immediately in addition to storing it, so that it impacts already initialized timers.

The motivation for this change is to allow Marlin firmware to utilize the latest version of this framework, without having to maintain workarounds to ensure proper interrupt priorities.

Validation

I verified this fix by reworking Marlin to build with the latest code from this repo. With this fix I am able to delete Marlin's HardwareTimer priority workarounds and custom copy of SoftwareSerial.

Without this change SoftwareSerial bit timing was inconsistent due to conflicting interrupts, causing communication errors.

HardwareTimer::setInterruptPriority previously stored the priority fur future use,
but it was typically never applied. It was applied only during the call to
HAL_TIM_Base_Init in the HardwareTimer constructor.

This change sets the priority immediately, in addition to storing it for future use by the HAL.
@fpistm
Copy link
Member

fpistm commented May 12, 2020

@sjasonsmith
any update on this ?

@sjasonsmith
Copy link
Contributor Author

@sjasonsmith
any update on this ?

I intend to come back to it, but this is hobby work for me and I am back to my day job at the moment.

Let me know if you were planning to make a new release or anything that would require me to rush this change in. Otherwise I expect to update it within the next couple days.

@fpistm
Copy link
Member

fpistm commented May 12, 2020

I'm currently preparing the next release and hope to release it this week or at least next week. That's why I ask. 😉

@sjasonsmith
Copy link
Contributor Author

I implemented the requested change to update the Capture/Compare interrupt. I'm only working with Update interrupts in Marlin, so I didn't have a way to test that change. This is still working as expected for the Update interrupt.

@fpistm fpistm added the enhancement New feature or request label May 13, 2020
@fpistm fpistm added this to the 1.9.0 milestone May 13, 2020
@fpistm fpistm merged commit 6b5f0ab into stm32duino:master May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants