Pages: [1]   Go Down
Author Topic: Pro Mini 5V @ 8MHz .. possible?  (Read 926 times)
0 Members and 1 Guest are viewing this topic.
Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So the Arduino IDE has two Pro Mini options for the 328P:

5V @ 16MHz or 3.3V @ 8MHz.

I presume one can also run it as a 5V @ 8MHz, but the question is, which bootloader to use then?  The reason I ask is because on a current project I need the 5V for a sensor, and it doesn't make much sense to have two regulators on board to drop the incoming 6V to both 3.3V as well as 5V, but at the same time, I don't need 16MHz ... for that matter, even 8MHz isn't needed.  I can probably run just fine at 1MHz (though I'd have to test that still.)

So what would I need to do to change that?  Looking in boards.txt, the two entries are nearly identical (except for the name) with the exception of the hex file being used as well as the following line:
pro5v.build.f_cpu=16000000L
to
pro328.build.f_cpu=8000000L

Low, high, and extended fuses are all the same.  Same for lock and unlock bits.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3540
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure I fully understand the problem here, what is wrong with running at 16MHz? Do you already have the Arduino? The Pro Mini has an onboard regulator. If you're dead set on running at 8MHz, get the 8MHz Pro Mini, feed it with the same 5V as used for the sensor (in that case, I'd check to ensure it's a LDO regulator).

The frequency listed in boards.txt does not set the MCU's clock frequency, it just tells the compiler what frequency the hardware runs at. So if you already have a 5V Pro Mini, the onboard resonator is a 16MHz part. If you're good with SMDs you might try to change it. There may be other options but give us some more background on the whole problem please.

Bootloaders are compiled to work at a particular clock frequency. Other folks here can advise better on that than I can. I recently used the Uno bootloader (compiled for 16MHz and 115,200bps upload speed) on an 8MHz system and it worked because I just happened to set the upload speed to 57,600, but that was just dumb luck. Still there may be other alternatives if you really need to slow the clock down for some reason.

Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I should've noted that I'm working on a custom design, not a pre-made board.  At the moment things are running off of a breadboard with a couple of 328Ps running with 5V @ 16MHz.  Ultimately, the project will be run off of batteries, so while there is nothing wrong with running it at 16MHz, I don't *need* it to run at that speed.  So for battery consumption, I'd like to drop that to 8MHz or maybe even 1MHz - that would still be just fine for what I'm doing ... I think.  Definitely 8MHz ... 1MHz remains to be seen.

Using the IDE, I burned the Pro Mini bootloader, and I picked the 5V @ 16MHz since that's the only 5V option from the IDE.  But I'd like to change the speed.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3540
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh! Then in that case, I think you can just burn an 8MHz bootloader and put in an 8MHz crystal or resonator. I'm pretty sure the "5V" designation in the IDE is just a clue for the user. The bootloader and compiler are aware of the clock frequency, but not of the supply voltage.

I'd also consider an ICSP programmer. Makes it a little simpler to work with other clock frequencies, not having to worry about the bootloader. I just add appropriate entries to boards.txt like below. For that matter, you could probably try 2MHz or 4MHz if 1MHz is too slow.

The other option is set the clock prescale register on the fly. I've only played with this a little, I think it's OK, as long as f_cpu in boards.txt is set to whatever value the clock will run at after setting CLKPR.

Code:
uno8i.name=Arduino Uno ICSP @ 8MHz
uno8i.upload.using=arduino:usbtinyisp
uno8i.upload.protocol=stk500
uno8i.upload.maximum_size=32256
uno8i.upload.speed=57600
uno8i.bootloader.low_fuses=0xff
uno8i.bootloader.high_fuses=0xd6
uno8i.bootloader.extended_fuses=0x05
uno8i.bootloader.path=optiboot
uno8i.bootloader.file=optiboot_atmega328.hex
uno8i.bootloader.unlock_bits=0x3F
uno8i.bootloader.lock_bits=0x0F
uno8i.build.mcu=atmega328p
uno8i.build.f_cpu=8000000L
uno8i.build.core=arduino
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, a buddy of mine is letting me borrow his serial stk500 programmer for me to play with.  Should be helpful at least.  I do still need to put an Arduino bootloader on since that's what I know to work with (for now.)

Ok, so if I picked the 3.3V @ 8 MHz Pro Mini bootloader, that doesn't mean the IC is running at 3.3V, just that it can go that low, but will also happily continue to tick if fed 5V?
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3540
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep, pretty sure I've done the same thing with an m328p on a breadboard. The speed/voltage relationship is a direct one: The higher the voltage, the faster the clock can run, but it can always run slower (and the MCU will draw less current). So when running an m328p at 3.3V, the fastest it can be clocked is around 8MHz or 10MHz. At 5V, it can go 16MHz (well, 20MHz actually). So the voltage determines the max clock speed, not vice versa.

See attached clip from the ATmega328P datasheet. Frequency is the dependent variable.


* ATmega328P Speed Grades.JPG (29.91 KB, 879x464 - viewed 7 times.)
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool, that should help shave some more electrons ... Danke!
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3540
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You bet. Good luck. Let us know how it works out. I've even seen suggestions to modify the clock prescale register on the fly, to slow down the processor when a lot of speed isn't needed, and speed it up for those times when it is. Of course doing this will throw a wrench into things like millis() and delay(), but those issues could be worked around if it's necessary to wring every last milliamp out.

Of course, all other things being equal, a lower supply voltage will result in less current. If I'm reading the chart in the datasheet right (p 508, Figure 30-331.ATmega328P: Active Supply Current vs. Frequency 1-20MHz), at 3.3V and 8MHz current is about 3mA, at 5V and 8MHz, about 5.5mA.
« Last Edit: October 31, 2011, 08:37:10 pm by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm still trying to figure out a good way to perform this test.  Essentially it's a 328p driving two strings of 10 LEDs each (each controlled by a WS2801), plus an RF module that's receiving a commend every 20 seconds.  The WS2801s each consume 1.5mA each under normal operation (not quite sure what "normal" means but hey, I'm not about to question anyone's state of "normal").  So with 20 of them, that's 30mA total for both strings.  They drive the LEDs through built-in opamps so I don't have to calculate what the LEDs are pulling.

The circuit itself consists of the 328p, resonator (no caps needed for that), two indicator LEDs, regulator with caps, the RF module, and headers.  The RF module will pull 12.3mA in receive mode (less in transmit).  That's it.

The last time I left one of these run, it ran overnight ... then the whole dang day ... then it failed some time after I went to bed the next day, which was a good 26+ hours after I turned it on.  But, it was also only running with one LED string.  So I need to another test with both strings attached.  My problem is, how to actually do this.  If it fails over night, I won't know WHEN it failed, just that it did.  So I need to figure something out here.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3540
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe write the time or even just a millis() value to EEPROM every minute or two? If you don't mind burning up some EEPROM life, it's only good for 100K writes smiley-lol
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since I don't have a time value, millis() is about the only thing I can use.  Hrm, I should probably write a small routine that takes the millis() value and convert it to a human readable time hh:mm:ss and store those values in EEPROM ...  I shall get to experimenting!
Logged

Pages: [1]   Go Up
Jump to: