Skip to content

Commit 7ea6570

Browse files
committed
Fixed setting HardwareTimer interrupt priority
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.
1 parent d3ba7fe commit 7ea6570

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cores/arduino/HardwareTimer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
/* Private Variables */
3636
timerObj_t *HardwareTimer_Handle[TIMER_NUM] = {NULL};
3737

38-
IRQn_Type getTimerUpIrq(TIM_TypeDef *tim);
39-
IRQn_Type getTimerCCIrq(TIM_TypeDef *tim);
40-
4138
/**
4239
* @brief HardwareTimer constructor: set default configuration values
4340
* @param Timer instance ex: TIM1, ...
@@ -913,6 +910,10 @@ void HardwareTimer::setPWM(uint32_t channel, PinName pin, uint32_t frequency, ui
913910
*/
914911
void HardwareTimer::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority)
915912
{
913+
// Set priority for immediate use
914+
NVIC_SetPriority(getTimerUpIrq(_timerObj.handle.Instance), NVIC_EncodePriority(NVIC_GetPriorityGrouping(), preemptPriority, subPriority));
915+
916+
// Store priority for use if timer is re-initialized
916917
_timerObj.preemptPriority = preemptPriority;
917918
_timerObj.subPriority = subPriority;
918919
}

0 commit comments

Comments
 (0)