Pro Mini ATmega168P 5V 16MHz

Hi, I am looking for advice on the following:

Scope: I would like to run a 5V Pro Mini with a 16MHz crystal to run at 3.3V and 8MHz

Questions:

  1. is running this board on its internal oscillator at 8MHz more accurate or less accurate regarding timing then using a Pro Mini ATmega168P 3.3V 8MHz with a RC external oscillator (not with a crystal)?
  2. how much more accurate regarding timing issues is a Pro Mini ATmega168P with an external crystal oscillator then one with an external RC oscillator?
  3. what are the standard L-fuse settings for a Pro Mini Atmega168P 5V 16MHz external crystal but running on internal oscillator at 8MHz?
    I found people using 0xe2, others 0xd2.
  4. If running a Pro Mini (equipped with an external 16MHz crystal) on its internal oscillator: is it fully decoupled from the external crystal (ie is the crystal not used in any way by the controller)?

Thks!

Erik

  • The internal oscillator is worse than a crystal, but good enough for quite a lot of things. If you need accurate timing though (such as for communication baud rates) go with a crystal.
  • Use a crystal if you’re worried about accuracy, it’s much easier.
  • Converting a 16MHz board to 8MHz is quite a nonstandard thing, so there are no standard settings to do it with. The difference between E2 and D2 is not that significant. You can look up the meaning of the fuse bits in the datasheet.
  • Should be.

What’s preventing you from just buying an 8MHz Pro Mini? They’re dirt cheap (<2USD) on ebay if you don’t mind waiting for the slow boat from China.

Jiggy-Ninja:

  • The internal oscillator is worse than a crystal, but good enough for quite a lot of things. If you need accurate timing though (such as for communication baud rates) go with a crystal.
  • Use a crystal if you’re worried about accuracy, it’s much easier.
  • Converting a 16MHz board to 8MHz is quite a nonstandard thing, so there are no standard settings to do it with. The difference between E2 and D2 is not that significant. You can look up the meaning of the fuse bits in the datasheet.
  • Should be.

What’s preventing you from just buying an 8MHz Pro Mini? They’re dirt cheap (<2USD) on ebay if you don’t mind waiting for the slow boat from China.

The 3.3V 8MHz version currently is twice as expensive as a regular 5V Pro Mini on Aliexpress.

I know, the timing it takes to do all the stuff to convert a 5V to a 8MHz pays itself back very largely when using a 3.3V instead. It actually is more about the challenge.

I already gave you a boards.txt file in the other thread, so you can have some fun with that instead. I know I had a lot of fun a while ago making my own with a ton of awesome options.

AVRs have a clock prescaler register that can divide the clock frequency down by powers of 2. There is a fuse setting that can make this divide by 8 by default, then you can change it later in code. You can use another Arduino as a programmer using the ArduinoISP sketch to change the fuse values and download the program.

I’ve attached a second revision of the hardware folder that adds a second menu option, whether to enable or disable the CLKDIV8 fuse. If you select it as enabled and burn the bootloader, the board will start with a 2MHz clock by default. You can then use the clock_prescale_set to set the prescaler to /2 instead of /8.

Or you can leave it at 2 MHz if you want and change the frequency in the boards.txt file. At 8MHz, the lowest voltage you’re recommended to use is 2.4V, but if you use 4MHz or lower you can use a supply voltage down to 1.8V. You could run the project off of 2 AA/AAA cells or a lithium coin cell.

There’s options. With the hand holding that the Arduino core does for you, it probably brings out less than 1/3 of the full capabilities of the AVR microcontroller.

hardware.zip (1.3 KB)

Jiggy-Ninja:
I already gave you a boards.txt file in the other thread, so you can have some fun with that instead. I know I had a lot of fun a while ago making my own with a ton of awesome options.

AVRs have a clock prescaler register that can divide the clock frequency down by powers of 2. There is a fuse setting that can make this divide by 8 by default, then you can change it later in code. You can use another Arduino as a programmer using the ArduinoISP sketch to change the fuse values and download the program.

I've attached a second revision of the hardware folder that adds a second menu option, whether to enable or disable the CLKDIV8 fuse. If you select it as enabled and burn the bootloader, the board will start with a 2MHz clock by default. You can then use the clock_prescale_set to set the prescaler to /2 instead of /8.

Or you can leave it at 2 MHz if you want and change the frequency in the boards.txt file. At 8MHz, the lowest voltage you're recommended to use is 2.4V, but if you use 4MHz or lower you can use a supply voltage down to 1.8V. You could run the project off of 2 AA/AAA cells or a lithium coin cell.

There's options. With the hand holding that the Arduino core does for you, it probably brings out less than 1/3 of the full capabilities of the AVR microcontroller.

Now THIS is an interesting post!!

This will give me weeks to do research.
Thanks a lot for the info.

The "handholding" is indeed a lid on creativity. I think we will talk some more in the future.

Thks,
Erik

Jiggy-Ninja:
AVRs have a clock prescaler register that can divide the clock frequency down by powers of 2.

I was not aware of this. Can you suggest some more reading about this? The link you gave sounds a bit like Chinese to me :wink:

Pretty sure I linked to the datasheet on this or the other thread. It has sections for everything that the chip is capable of. the AVRLibc website has a bunch of functions that make setting the registers up a lot easier.

A "blink 1 second" program is compiled as 5V 16MHz Pro Mini, cycles run at exactly 1 second. OK.

Next trial: I set the CKDIV8 bit checked (active) and the result is a blink every 8 seconds. OK.
(see: AVR® Fuse Calculator – The Engbedded Blog, and use avrduded GUI or avrdudess GUI for easy of programming fusebits).

Next trial: I keep CKDIV8 bit checked and compile as 8MHz 3.3V Pro Mini; the result is a blink every 4 seconds: OK (compiler told it runs at 8MHz yet clock is at 2MHz makes the program run 4 times slower as intended.

Next trial: I change the boards.txt at the Pro Mini 3.3V location:

## Arduino Pro or Pro Mini (3.3V, 2 MHz) w/ ATmega168

--------------------------------------------------

(8MHz lready substituted by 2MHz)

to:

pro.menu.cpu.8MHzatmega168.build.f_cpu=2000000L

(was 8000000L)

Upload same sketch, keep CKDIV8 active. Result: blink ervery second. OK

Conclusion: running a Pro Mini 5V with a 16MHz crystal at 3.3V, and lower the frequency to an acceptable (see datasheet) value then it is perfectly executable, with 2 software changes: one in boards.txt and 1 fusebit.

Page 31/660 ofthe datasheet:
If the cryatal frequency exceeds the specification of the device (depends on VCC), the CKDIV8 Fuse can be
programmed in order to divide the internal frequency by 8. It must be ensured that the resulting divided clock
meets the frequency specification of the device.

This may seem like kicking in open doors, but I had my reservations about using a 16MHz crystal (and in fact oscillator) on 3.3V as Atmel says you should not run this processor at 16MHz at 3.3V.
Now this simple datasheet text, and this simple test confirms it is possible to run 5V Pro Mini
safely,
accurately
and reliably
at 3.3V

Also an incentive to do this is the fact that currently 3.3V Pro Mini's sell for at least twice the price as 5V versions on Aliexpress.

At 2 MHz you can run the sucker all the way down to 1.8V.

…Except for one other fuse setting that will stop you. I’ll leave it to you to figure out what you would need to change and what you would need to change it to.

Jiggy-Ninja:
At 2 MHz you can run the sucker all the way down to 1.8V.

...Except for one other fuse setting that will stop you. I'll leave it to you to figure out what you would need to change and what you would need to change it to.

BODLEVEL0 set to active :slight_smile:

brice3010:
BODLEVEL0 set to active :slight_smile:

Record setting for response time hehe

Jiggy-Ninja:
At 2 MHz you can run the sucker all the way down to 1.8V.

Imagine the powersavings involved. And 99% of programs need not run faster.

brice3010:
Imagine the powersavings involved. And 99% of programs need not run faster.

I don't need to imagine, I know. I did a school protect involving an ATtiny84 + nRF24L01+ that transmitted once every 1.5s (on average), and we estimated 1 month of battery life from a CR2032 coin cell.

Jiggy-Ninja:
I don't need to imagine, I know. I did a school protect involving an ATtiny84 + nRF24L01+ that transmitted once every 1.5s (on average), and we estimated 1 month of battery life from a CR2032 coin cell.

"school protect": you mean burglary protection? I am very interested, maybe if you want, can you send me a project overview or description? Thanks a lot!

Proposal, final report, and the code for both units. Unfortunately the final presentation is too big due to the images we used. It does not use an Arduino core, we actually used WinAVR to write and compile the programs. I arbitrarily made the decision for the group to not use an Arduino, just to try something a little new. So we settled on ATtiny84V. It’s still an AVR, so a lot of the same ideas can be used for an ATmega168P or ATmega328P.

Project Files.zip (164 KB)

Jiggy-Ninja:
Proposal, final report, and the code for both units. Unfortunately the final presentation is too big due to the images we used. It does not use an Arduino core, we actually used WinAVR to write and compile the programs. I arbitrarily made the decision for the group to not use an Arduino, just to try something a little new. So we settled on ATtiny84V. It's still an AVR, so a lot of the same ideas can be used for an ATmega168P or ATmega328P.

I just read the files: very interesting! I send you a pm tomorrow.
Erik