Skip to content

Commit

Permalink
Better STM32 Tone timer int priority (#18385)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjasonsmith authored Jun 22, 2020
1 parent 819e489 commit e52afa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Marlin/src/HAL/STM32/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
#define TEMP_TIMER_IRQ_PRIO 14 // 14 = after hardware ISRs
#endif

// Ensure the default timer priority is somewhere between the STEP and TEMP priorities.
// The STM32 framework defaults to interrupt 14 for all timers. This should be increased so that
// timing-sensitive operations such as speaker output are note impacted by the long-running
// temperature ISR. This must be defined in the platformio.ini file or the board's variant.h,
// so that it will be consumed by framework code.
#if !(TIM_IRQ_PRIO > STEP_TIMER_IRQ_PRIO && TIM_IRQ_PRIO < TEMP_TIMER_IRQ_PRIO)
#error "Default timer interrupt priority is unspecified or set to a value which may degrade performance."
#endif

#if HAS_TMC_SW_SERIAL
#include <SoftwareSerial.h>
#ifndef SWSERIAL_TIMER_IRQ_PRIO
Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ build_flags = ${common.build_flags}
-IMarlin/src/HAL/STM32 -std=gnu++14
-DUSBCON -DUSBD_USE_CDC
-DUSBD_VID=0x0483
-DTIM_IRQ_PRIO=13
build_unflags = -std=gnu++11
src_filter = ${common.default_src_filter} +<src/HAL/STM32>

Expand Down

0 comments on commit e52afa8

Please sign in to comment.