Reduce AVR clock to 8MHz

This commit is contained in:
Jeremy Soller 2020-11-05 12:49:07 -07:00
parent ac59886d3f
commit 84a11e746f
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 10 additions and 2 deletions

View File

@ -4,8 +4,10 @@ MCU = atmega32u4
# Allow flashing with usbasp
AVRDUDE_MCU = $(MCU)
# Processor frequency
F_CPU = 16000000
# CPU frequency divided by two since AVR is at 3.3V
F_CPU = 8000000
# External oscillator is 16Mhz
F_USB = 16000000
# Bootloader selection
# Teensy halfkay

View File

@ -917,8 +917,14 @@ static void setup_mcu(void) {
MCUSR &= ~_BV(WDRF);
wdt_disable();
// HACK for System76 boards with AVR at 3.3V and crystal at 16 MHz
#if (F_CPU == 8000000 && F_USB == 16000000)
/* Divide clock by 2 */
clock_prescale_set(clock_div_2);
#else
/* Disable clock division */
clock_prescale_set(clock_div_1);
#endif
}
/** \brief Setup USB