🩹 Teensy 4.x timer mods

This commit is contained in:
Scott Lahteine
2025-11-14 13:09:40 -06:00
parent 1c6b723ee6
commit 8cd9c06084
+14 -6
View File
@@ -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 compareevent 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 (logichigh 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 compareevent 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 (logichigh 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;
}
}