1

I am currently using ATMega32U4 running at 16MHz using Leonardo. I can only supply 3.7V (I use LiPo batteries) and everything seems fine but this is not as per specs.

To run at 16 MHz, I have to supply 5V but I can't. I do not want to do any step-up. I am thinking of of using 8 MHz crystal so the processor will require only 3.3V, but I need to use a Leonardo.

Has anyone been successful in doing this?

  • Why do you "need" Leonardo? – Ignacio Vazquez-Abrams Sep 21 '15 at 0:47
  • Has who been successful? To whom are you addressing this? – Majenko Sep 21 '15 at 9:26
  • Or is this a general survey? Finding out what proportion of the population have been successful in using an 8MHz bootloader on a Leonardo? – Majenko Sep 21 '15 at 10:04
1

The bootloader does USB. I don't think you can do USB on the 32u4 on only 8mHz.

You can however set the system clock prescaler to divide the main clock by 2, making it run at 8mHz. The bootloader will however still run at 16mHz, but that's probably still fine (though out of spec).

The AVR USB has a system clock prescaler, and the system clock can be divided by setting the “CLKPR – Clock Prescaler Register” on page 38. This feature can be used to decrease the sys- tem clock frequency and the power consumption when the requirement for processing power is low. This can be used with all clock source options, and it will affect the clock frequency of the CPU and all synchronous peripherals. clkI/O, clkADC, clkCPU, and clkFLASH are divided by a factor as shown in Table 6-10.

To divide the system clock by 2, set the CLKPS0 bit in the CLKPR register. The code for this would be something like this:

void setup()
{
  cli();
  CLKPR = _BV(CLKPCE);
  CLKPR = _BV(CLKPS0);
  sei();

  ...

just note that everything runs twice as slow. So delay(1000) will take 2 seconds. You'll have to update F_CPU somehow to fix this if this causes a problem.

  • 1
    You can do USB on 8MHz. The first thing that happens to the 16MHz clock on its way to the USB PLL is it goes through a /2 prescaler. That prescaler can be bypassed to make it /1 so it can run from 8MHz. It's all in the datasheet. These bits allow to configure the PLL input prescaler to generate the 8MHz input clock for the PLL from either a 8 or 16MHz input. – Majenko Sep 21 '15 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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