Author Topic: Running AVR (Attiny85) with 16MHz external clock F_CPU 8MHz system clock @3.9Vcc  (Read 2200 times)

0 Members and 1 Guest are viewing this topic.

Offline eneuroTopic starter

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
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.5V  :popcorn:
I'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   ?!  :o

12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 7344
  • Country: ro
Tested once a 16MHz ATmega32/5V with a 20MHz quartz, and apparently was working OK.  :D
Didn't measure the current.  Eventually replaced the 20MHz quartz with a 16MHz one, to be sure it will run reliably.

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 2355
  • Country: au
What do you think about MPU power consumption while running Attiny85 with 16MHz quartz external clock and system clock downgraded to 8MHz @3.3Vcc   ?!  :o
The 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
« Last Edit: August 20, 2023, 07:06:34 am by PCB.Wiz »
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 15549
  • Country: de
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.
 

Offline eneuroTopic starter

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
At low Vcc you can expect the oscillator to not start at 16MHz ( as the gain drops away)
I'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: [Select]
int main() {
#ifndef F_CPU
#define F_CPU 8000000UL // 8MHz system clock wanted
#endif
        cli();
        // Disable pull-up on all pins
        avr_pull_ups_disable();
        avr_system_clock_init(); // Switch to given F_CPU system clock frequency
        // Delay 1 second eg. after vcc drop reset
        avr_delay_s( 1 );
        // Enable interrupts
        sei();
...
} // main

AVR Attiny85 Low fuse bit 7:
« Last Edit: August 20, 2023, 08:54:58 am by eneuro »
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6572
  • Country: es
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.

« Last Edit: August 20, 2023, 11:56:51 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline eneuroTopic starter

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
Don't expect your mcu to run at 3.9V, li-ion starts at 4.2V but quickly drops and stabilizes at ~3.7V.
Nope, My 18650 Li-on battery will never start to discharge at 4.2V, because of it is charged to 3.9Vmax  :-DD and 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 minimum  8)
So, 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  :popcorn:
« Last Edit: August 20, 2023, 04:45:43 pm by eneuro »
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline eneuroTopic starter

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
..., li-ion starts at 4.2V but quickly drops and stabilizes at ~3.7V.
So, 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 100mAmax  8)

Now 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)  :-/O

12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf