mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-17 19:57:57 -06:00
avr: Add config option to clear the CPU prescaler
Some AVR chips ship with a 1/8th clock divisor set. Add a compile time option to manually clear this field at startup. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
38f1d78e1b
commit
91e7807af6
2 changed files with 23 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include <avr/interrupt.h> // TCNT1
|
||||
#include "autoconf.h" // CONFIG_AVR_CLKPR
|
||||
#include "command.h" // shutdown
|
||||
#include "irq.h" // irq_save
|
||||
#include "sched.h" // sched_timer_kick
|
||||
|
@ -49,6 +50,14 @@ ISR(TIMER1_COMPA_vect)
|
|||
static void
|
||||
timer_init(void)
|
||||
{
|
||||
if (CONFIG_AVR_CLKPR != -1 && (uint8_t)CONFIG_AVR_CLKPR != CLKPR) {
|
||||
// Program the clock prescaler
|
||||
uint8_t flag = irq_save();
|
||||
CLKPR = 0x80;
|
||||
CLKPR = CONFIG_AVR_CLKPR;
|
||||
irq_restore(flag);
|
||||
}
|
||||
|
||||
// no outputs
|
||||
TCCR1A = 0;
|
||||
// Normal Mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue