Running AVR (Attiny85) with 16MHz external clock F_CPU 8MHz system clock @3.9Vcc - Page 1
Forum section: electronics / general

author: eneuro
author_rank: Super Contributor
timestamp: August 20, 2023, 04:55:24 am
content: Hello,I've AVR (Attiny85) with 16MHz external clock F_CPU 8MHz system clock @3.9Vcc and it looks like it works fine since we have such speed grades for this MPU: ATtiny25/45/85: 0 – 10 MHz @ 2.7 - 5.5V, 0 - 20 MHz @ 4.5 - 5.5VI'm interested in 2.7Vcc-3.9Vcc since it is powered directly from 18650 Li-on battery (4.2Vbat max) with BOD level 2.7V typical, so I can change in software AVR system clock speed to slow down this tiny MPU from 16MHz -> 8MHz when it has <4.5Vcc to ensure Attiny85 works in given speed grades.What do you think about MPU power consumption while running Attiny85 with 16MHz quartz external clock and system clock downgraded to 8MHz @3.3Vcc ?!

author: RoGeorge
author_rank: Super Contributor
timestamp: August 20, 2023, 05:43:12 am
content: Tested once a 16MHz ATmega32/5V with a 20MHz quartz, and apparently was working OK.Didn't measure the current. Eventually replaced the 20MHz quartz with a 16MHz one, to be sure it will run reliably.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: August 20, 2023, 06:32:37 am
content: Quote from: eneuro on August 20, 2023, 04:55:24 amThe internal divider should let you pick a MHz / Vcc space that is ok, but one detail that Atmel do not specify, is the Crystal Oscillator vs Vcc.At low Vcc you can expect the oscillator to not start at 16MHz ( as the gain drops away)You can help things by picking a crystal with low CL and low ESR. You can also test oscillator start margin, by adding a series resistor to the crystal.Addit : tiny parts can be worst. lcsc shows 2016 package 16MHz with 200 or 270 ESR, which is high. In larger packages that can come down to 30/35/40 ohms

author: Kleinstein
author_rank: Super Contributor
timestamp: August 20, 2023, 07:04:46 am
content: The specs for the AVRs usually have quite some reserve, e.g. for running at higher temperature (up to the automotive range). So chances are relatively high they would run faster (or with a lower Vcc) than the specs guarantee.The oscillator is OK to run faster than the CPU specs. So 16 MHz should be no problem even with a lower voltage (maybe down to some 2 V). AFAIK there are not extra specs for this, but given that an oscillator is relatively simple the oscillator itself should be OK and likely would also run way faster than 20 MHz.The question is if one really needs the speed. If the SW is OK to reduce the speed - does it need the extra speed at all ?Many µC applications don't need the full speed and can run at a rather moderate clock (e.g. 1 MHz range). Power wise it would even save a little to have a low power regulator to reduce the voltage to lets say 2.7 V all the time. A slower crystal also tends to need less power and produces less EMI.

author: eneuro
author_rank: Super Contributor
timestamp: August 20, 2023, 08:52:40 am
content: Quote from: PCB.Wiz on August 20, 2023, 06:32:37 amI've also programmed low fuse bit 7 divide clock by 8 with external (quartz) clock enabled, so I hope I've Attiny85 running 2MHz system clock F_CPU after start/restart, than I switch in software to 8MHz at the beginning of main AVR MPU code, so I hope it shouldn't be a problem to start MPU at lower Vcc vs. speed grade and it works @3.9Vcc while powered from 18650 Li-on battery:Code:int main() {#ifndef F_CPU#define F_CPU 8000000UL // 8MHz system clock wanted#endifcli();// Disable pull-up on all pinsavr_pull_ups_disable();avr_system_clock_init(); // Switch to given F_CPU system clock frequency// Delay 1 second eg. after vcc drop resetavr_delay_s( 1 );// Enable interruptssei();...} // mainAVR Attiny85 Low fuse bit 7:

author: DavidAlfa
author_rank: Super Contributor
timestamp: August 20, 2023, 11:54:17 am
content: Don't expect your mcu to run at 3.9V, li-ion starts at 4.2V but quickly drops and stabilizes at ~3.7V.Also 2.7V discharge is very low for li-ion, will damage it a lot more than using the more usual cutoff voltage of ~3.5V.It's the opposite to the older Nickel-based batteries, where you needed full discharge cycles to prevent battery damage.The more you dicharge Li-ion, the more it wears out, i.e charging at 80% is just fine, won't cause any harm.

author: eneuro
author_rank: Super Contributor
timestamp: August 20, 2023, 04:43:26 pm
content: Quote from: DavidAlfa on August 20, 2023, 11:54:17 amNope, My 18650 Li-on battery will never start to discharge at 4.2V, because of it is charged to 3.9Vmaxand this can extend its lifespan, since it can make more charge/discharge cycles.Discharge voltage as low as around ~2.7V it is worst case when ATTiny85 with BOD enabled for 3.3Vcc powered directly from 18650 Li-on battery will stop working when Vcc will be as low as typical 2.7Vcc BOD level @ 3.3Vcc and it is slightly above flat Li-on battery 2.5Vbat minimumSo, Attiny85 BOD level for 3.3Vcc programmed by using AVR BOD fuse bit is is simply used as additional 18650 Li-on battery over discharge protection, because of MPU itself can sometimes from time to time make its Vcc voltage measurements and go into sleep mode eg. while running <3Vcc

author: eneuro
author_rank: Super Contributor
timestamp: August 20, 2023, 10:50:53 pm
content: Quote from: DavidAlfa on August 20, 2023, 11:54:17 amSo, that is why I've decided increase lifespan of 18650 Li-on batteries by charging only to 3.9Vmax and also charging current of each 18650 is limited to around 100mAmaxNow I'm going to test such circuit from LM317 TI datasheet with current limit Iout ~100mA set by R3 and estimated maximum output voltage ~3.9Vout to charge 18650 Li-on (4.2Vmax)