1
\$\begingroup\$

I have an already-designed board that uses an ATmega32U4 (a board of our own design). It is USB-powered at 5V and it has an external 16MHz crystal.

Below is a screencapture of the relevant portion of the schematic:

enter image description here

The firmware is built as an Arduino project (a single .ino file), based on the Pro Micro.

I have several reasons to move the design to 3.3V (still USB-powered, so I can simply add an LDO to generate the 3.3V); thus, the external crystal will have to be 8MHz. However, my doubt/question is about the 48MHz internally-generated USB clock signal: I don't see anywhere in the .ino file anything related to setting up the MCU's PLL; would that be part of the bootloader? Would I need to adjust the bootloader? Obtain and flash a bootloader image specifically for 8MHz clock?

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

I think the bootloader uses this module to initialize the USB hardware: USBCore.cpp

This is the relevant code fragment:

// ATmega32U4
#if defined(PINDIV)
#if F_CPU == 16000000UL
    PLLCSR |= (1<<PINDIV);                   // Need 16 MHz xtal
#elif F_CPU == 8000000UL
    PLLCSR &= ~(1<<PINDIV);                  // Need  8 MHz xtal
#else
#error "Clock rate of F_CPU not supported"
#endif
 

I think you must recompile the bootloader with the option

F_CPU = 8000000

in the caterina Makefile or try to use the caterina-LilyPadUSB bootloader. That seems to be compatible to your design and expects an 8 MHz crystal.

\$\endgroup\$
2
  • \$\begingroup\$ Sorry it took me a while to mark it as answered; I was tempted to do so as soon as I was convinced that this was the correct answer, but then I figured I'd wait to receive and try the boards — that took longer than anticipated, but finally yesterday we received them, and indeed things worked following your suggestion! \$\endgroup\$
    – Cal-linux
    Mar 9 at 18:33
  • \$\begingroup\$ BTW, we just downloaded the binary (caterina-LilyPadUSB.hex) and flashed it, and then we could flash the Arduino code via the USB. \$\endgroup\$
    – Cal-linux
    Mar 9 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.