Skip to content

Commit

Permalink
Set priority for Capture/Compare if different IRQ than Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sjasonsmith committed May 13, 2020
1 parent 7ea6570 commit ebf27ee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cores/arduino/HardwareTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,13 @@ void HardwareTimer::setPWM(uint32_t channel, PinName pin, uint32_t frequency, ui
*/
void HardwareTimer::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority)
{
// Set priority for immediate use
NVIC_SetPriority(getTimerUpIrq(_timerObj.handle.Instance), NVIC_EncodePriority(NVIC_GetPriorityGrouping(), preemptPriority, subPriority));
// Set Update interrupt priority for immediate use
HAL_NVIC_SetPriority(getTimerUpIrq(_timerObj.handle.Instance), preemptPriority, subPriority);

// Set Capture/Compare interrupt priority if timer provides a unique IRQ
if (getTimerCCIrq(_timerObj.handle.Instance) != getTimerUpIrq(_timerObj.handle.Instance)) {
HAL_NVIC_SetPriority(getTimerCCIrq(_timerObj.handle.Instance), preemptPriority, subPriority);
}

// Store priority for use if timer is re-initialized
_timerObj.preemptPriority = preemptPriority;
Expand Down

0 comments on commit ebf27ee

Please sign in to comment.