From 8cd9c0608417849149d8de6052961eeb5fbf0236 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 14 Nov 2025 13:09:40 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Teensy=204.x=20timer=20mods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/TEENSY40_41/timers.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Marlin/src/HAL/TEENSY40_41/timers.cpp b/Marlin/src/HAL/TEENSY40_41/timers.cpp index 362bd4e06d..011f9fe31c 100644 --- a/Marlin/src/HAL/TEENSY40_41/timers.cpp +++ b/Marlin/src/HAL/TEENSY40_41/timers.cpp @@ -55,15 +55,19 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { GPT1_OCR1 = (GPT1_TIMER_RATE / frequency) - 1; // Enable compare‑event interrupt - GPT1_IR = GPT_IR_OF1IE; // OF2 interrupt enabled - GPT1_CR |= GPT_CR_EN; //enable GPT2 counting at 150 MHz + GPT1_IR = GPT_IR_OF1IE; // OF1 interrupt enabled - OUT_WRITE(15, HIGH); + // Pull Pin 15 HIGH (logic‑high is the “idle” state) + TERN_(MARLIN_DEV_MODE, OUT_WRITE(15, HIGH)); // Attach and enable Stepper IRQ // Note: UART priority is 16 attachInterruptVector(IRQ_GPT1, &stepTC_Handler); NVIC_SET_PRIORITY(IRQ_GPT1, 16); // Priority 16 (higher than Temp Timer) + + // Start GPT1 counting at 150 MHz + GPT1_CR |= GPT_CR_EN; + break; // @@ -90,14 +94,18 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { GPT2_OCR1 = (GPT2_TIMER_RATE / frequency) - 1; // Enable compare‑event interrupt - GPT2_IR = GPT_IR_OF1IE; - GPT2_CR |= GPT_CR_EN; //enable GPT2 counting at 150 MHz + GPT2_IR = GPT_IR_OF1IE; // OF1 interrupt enabled - OUT_WRITE(14, HIGH); + // Pull Pin 14 HIGH (logic‑high is the “idle” state) + TERN_(MARLIN_DEV_MODE, OUT_WRITE(14, HIGH)); // Attach Temperature ISR attachInterruptVector(IRQ_GPT2, &tempTC_Handler); NVIC_SET_PRIORITY(IRQ_GPT2, 32); // Priority 32 (lower than Step Timer) + + // Start GPT2 counting at 150 MHz + GPT2_CR |= GPT_CR_EN; + break; } }