I've been able to successfully burn bootloaders on arduino. I'm trying to decrease the power consumption so I'm trying to replace the 16MHz external crystal oscillator to 1MHz.
It has settings for 0.9-3MHz, but there are multiple settings. Rather than trying a random one, and possibly brick my atmega, I wanted to ask someone that knows what they are doing.
I was wondering if you could direct me to the proper fuse settings for 3.3V, 1MHz, atmega328p? This will be very helpful. Thank you very much for your time.
Also another question, when you set up the arduino IDE, and say I have this in my boards.txt, with the empty.hex etc, so that it can program for 1MHz. I know this might be a dumb question but I wanted to verify that I should always be able to program over and over using the arduino IDE with the 1MHz crystal?
samcoder:
I guess that is where i got confused, i thought the divide was only for the internal oscillator,
I believe the clock divider works no matter what the "base" clock is.
but I wanted to use a 1MHz external crystal.
Well, I'm afraid someone else may have to help. That is an option I've never tried.
So would I then use an 8MHz external crystal and then use the divide by 8 option?
I believe that would work as well.
But, I believe you well get the greatest power savings by using the internal oscillator. There is a price to pay, however. The internal oscillator is not nearly as accurate as an external crystal. Atmel only guarantees ±10% from the factory. The internal oscillator can be tuned to ±1%. If you need a clock more accurate than that or you do not want to fiddle with tuning then an external crystal is a better choice.
I'm actually trying to make a binary watch, so I'm trying to get the lowest power for the performance. Would the internal clock be too bad for this kind of timing application?
samcoder:
I've been successful in burning bootloaders with USBasp since it was included in arduino ide, so maybe with bootloaders.
If the processor is clocked at 1 MHz and you want to use optiboot# you will either have to rebuild the bootloader yourself so it runs correctly at 1 MHz, beg westfw to rebuild the bootloader for you, or upload at 115200 / 16 = 7200 baud.
To rebuild the bootloader, I had noticed in another post that you just changed the fuse information for the high, low, extended, and then created an empty sketch that you compiled using the arduino ide, and then tagged it to the boards.txt in hardware. Could I do this to create this new board?
samcoder:
I'm actually trying to make a binary watch, so I'm trying to get the lowest power for the performance. Would the internal clock be too bad for this kind of timing application?
Yes. The internal oscillator's frequency depends on supply voltage (which you could keep stable using a regulator) and temperature (which you will have a difficult time controlling with a watch). If you could keep supply voltage and temperature very stable then it would work OK; you'd have to adjust the watch about once a week.
For a low power clock the best choice is either...
• A "watch crystal" connected to one of the timers (I think it's timer 2 that has an asynchronous mode). As you would expect, very accurate "watch crystals" are available. The downside to this solution is that it is a bit tricky to get it working and, to get the highest possible accuracy, the crystal has to have just the right capacitors.
samcoder:
To rebuild the bootloader, I had noticed in another post that you just changed the fuse information for the high, low, extended, and then created an empty sketch that you compiled using the arduino ide, and then tagged it to the boards.txt in hardware. Could I do this to create this new board?
I suspect your definition of "bootloader" is different than mine. What you're describing is a convenient method of changing the target's fuses using an ISP (in-system programmer).
Lol, i've been trying to find it again....when I do I'll post. I've been searching every where before i posted, i should have saved links. I guess I do have an ISP programmer know as USBasp that directly connects to MISO SCK RESET MOSI. I just forgot that i was able to directly code onto the chip without putting a bootloader. So yes, i do believe i have an ISP programmer, lol.
So basically with USBasp I can directly code onto the arduino using the arduino IDE environment. I just need to upload using programmer.
So, to make it work I would just need to program the correct fuse information like in the link, and add another board to my boards.txt with the fuse information, and empty bootloader. Then burn bootloader. The next step is to upload programmer with new crystal in place, does that sound right?
That is essentially a hack to avoid using the command-line. It uses the IDE in a way that it was not meant to be used. And I certainly understand why you are confused about "bootloaders" after reading it.
A bootloader takes the place of an ISP (like your USBasp). It's a bit of software that cohabitates with the application on the target processor. Essentially, its like the processor carries an ISP with it where ever it goes. However, there are some things a bootloader cannot do that an ISP can do; like changing the fuses.
For what you are trying to do, an ISP is a better choice. Just one word of caution ... proceed carefully when you change the fuses. There are fuse settings that will "brick" the processor. The processor can be recovered but only through the use of a "high voltage parallel" programmer.
samcoder:
So basically with USBasp I can directly code onto the arduino using the arduino IDE environment. I just need to upload using programmer.
Exactly.
So, to make it work I would just need to program the correct fuse information like in the link, and add another board to my boards.txt with the fuse information, and empty bootloader. Then burn bootloader. The next step is to upload programmer with new crystal in place, does that sound right?
If you have an external crystal oscillator (rather than bare crystal) then the ATmega oscillator setup fuses are less critical - just try connecting the external 1MHz source via a 1k resistor to the XTAL1 pin (which is the oscillator input), don't connect the XTAL2 pin, seems to work for me.
Thank you all for the information, I have two different experiments I want to try. The first is programming the internal 8MHz clock, with the divide by 8 option to achieve the 1MHz clock. The second is to use a 8MHz external crystal, and divide by 8 option to achieve 1MHz.
I will try the following fuse settings. I will try them out on a spare amtega328p I have lying around.
Fuse settings for 8MHz internal, divide by 8:
Low High Extend
So I tried it for the internal 8MHz with 8 div to achieve 1MHz, and I noticed that the power consumption was around 7mA @ 5.2V, and 1.5mA @ 3.3V.
I think I'm going to go in this route, since I wouldn't mind sacrificing some precision for power. I'll take 1.5mA @3.3V any day for a fully active arduino.