Skip to content

Commit 0fb3ed4

Browse files
thinkyheadernisv
authored andcommitted
🎨 Timer tweaks
1 parent 5d93546 commit 0fb3ed4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Marlin/src/HAL/AVR/timers.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ typedef uint16_t hal_timer_t;
4444
#define MF_TIMER_TEMP 0
4545
#endif
4646

47-
#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0)
47+
#define TEMP_TIMER_FREQUENCY (((F_CPU) + 0x2000) / 0x4000)
4848

4949
#define STEPPER_TIMER_RATE HAL_TIMER_RATE
5050
#define STEPPER_TIMER_PRESCALE 8
51-
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double
51+
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000)
5252

53-
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer
54-
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
53+
#define PULSE_TIMER_RATE STEPPER_TIMER_RATE
54+
#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE
5555
#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
5656

5757
#define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A)

Marlin/src/HAL/ESP32/timers.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
111111
/**
112112
* Set the upper value of the timer, when the timer reaches this upper value the
113113
* interrupt should be triggered and the counter reset
114-
* @param timer_num timer number to set the count to
115-
* @param count threshold at which the interrupt is triggered
114+
* @param timer_num timer number to set the compare value to
115+
* @param compare threshold at which the interrupt is triggered
116116
*/
117-
void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) {
117+
void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
118118
const tTimerConfig timer = timer_config[timer_num];
119-
timer_set_alarm_value(timer.group, timer.idx, count);
119+
timer_set_alarm_value(timer.group, timer.idx, compare);
120120
}
121121

122122
/**

0 commit comments

Comments
 (0)