Go Down

Topic: arduino with internal oscillator on 1Mhz (Read 40 times) previous topic - next topic

TBAr

#25
Dec 02, 2009, 11:39 pm Last Edit: Dec 03, 2009, 01:03 am by TBAr Reason: 1
Marvin Martian, why do you think you would need to reprogram the bootloader?

You also said
Quote
Comms is not an issue as I'm programming the 328 in an Arduino then taking it out and dropping it in my PCB.

So when you want to reprogram the sketch on the 328, pull it out of your PCB, replace the 328 in your Arduino (which still has the 16MHz crystal) and re-program the sketch there.

[edit]I know there are timing issues with some of the libraries when they are used with a crystal other than the 16MHz one. But it still seems that is separate from the bootloader issue. If the logic in the sketch cannot be adjusted for a lower crystal speed, there is no point in changing the bootloader anyway. If the logic can be adjusted or does not need to be adjusted, the procedure I outline above should still be valid without needing to reprogram another bootloader onto the 328. At power-on, the standard Arduino bootloader may take a little longer (at the reduced crystal speed) to recognize that there is no data coming in on the serial port, but it should eventually time out and start the sketch anyway, right?[/edit]

Marvin Martian

Quote
Marvin Martian, why do you think you would need to reprogram the bootloader?


Because of what mungbean said earlier:
Quote
As I understand it, clock speed is hard-coded into the bootloader, so changing the crystal isn't enough to change the speed.  You would need to program a new bootloader in as well.


So I'm still confused as to whether this is or is not necessary  :-/


tytower

#27
Dec 03, 2009, 01:46 pm Last Edit: Dec 03, 2009, 02:04 pm by tytower Reason: 1
Spookyman166
Quote
Why reprogram the arduino when you can just buy a crystal for 2 bucks


Personaly I have a box full of old crystals I'd like to use up. As I am presently at a river mouth  about to head  to sea I would have to allow two days to tie up ,catch a cab 40Ks to the parts shop, buy my crystal and catch a cab back.

I  find it cheaper to reprogram it.
Its all a matter of your own circumstances and then how narrow or broad your vision is.

Marvin I am using a 14.890MHz crystal in an ATMega8 because of the above . To get the chip to run I have to change the Makefile and recompile the bootloader allowing for this crystal speed . I also have to create a board in "boards.txt" to get an entry for my board

If I program the chip with a sketch in a standard duelmilanov board with a 16MHz crystal and put a standard bootloader on the chip first it will all go off OK. When I put it back in my experimental board with the slower crystal the sketch will run just a little slower but not that I can notice ,however I cannot upload another sketch to it unless I put it back in the standard board



mungbean

Marvin Martian -- if all you want to do is reduce power consumption, then you can change the clock speed once you've booted (in your setup function), as described above.

I posted some test figures earlier in the thread, showing the reduction in current for various clock speeds.  If it's possible to put the arduino to sleep for longish periods of time when it's not doing anything, then this will save power further.

If you want to run on a LOWER VOLTAGE, then you may need to reprogram the bootloader to get the arduino to bootup on that lower voltage, depending on how low you want to go.

I'm basing this assumption on what we found in the ATmega328 datasheet, again mentioned earlier in the thread.

I'm beginning to think it would be GREAT to have a slightly modified bootloader that selected clock frequency based on some jumpers on the board. Anyone fancy giving us an early christmas present...? ;-)


tytower

Back on page 1 wolfpaulus said
Quote

The last thing that needs to be done is adjusting the Arduino IDE preferences file: ~/Library/Arduino/preferences.txt on the Mac and C:\Documents and Settings\<USERNAME>\Application Data\Arduino\preferences.txt on Windows:
The build.f_cpu preference needs to be set to 1000000L


I see that on Linux "preferences.txt " is in the library directory and I could find no mention of "build.f_cpu".

Is this now obsolete ?

Go Up