Author Topic: Switching to 8MHz operation, what is in volved  (Read 2849 times)

themzlab

  • NewMember
  • *
  • Posts: 4
Switching to 8MHz operation, what is in volved
« on: September 20, 2014, 09:29:37 AM »
hi all,

I am migrating from Arduino world to Moteino and also starting my first battery project.  I have found I may not need all the speed of 8MHz but the application is not one that just can wake, read a sensor quickly and shut off again.    I have not done any ISP programming or non Arduino IDE programming.

What is involved in switching to 8 MHz.  Would I need to re-flash the bootloader?  Edit libraries? or is there a constant somewhere that can be changed?

Sorry for the noob and relatively open-ended question.  Guess I'm just looking to get some idea of the scope for this endeavor.

thanks!

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6617
  • Country: us
    • LowPowerLab
Re: Switching to 8MHz operation, what is in volved
« Reply #1 on: September 20, 2014, 10:09:16 AM »
Well the resonator used on Moteinos is 16mhz. You can't change that.
You can change the fuses on the MEGA to not use it and instead use the internal 8mhz oscillator.
Also you can divide the clock source in software, see this link for that: http://playground.arduino.cc/Code/Prescaler

themzlab

  • NewMember
  • *
  • Posts: 4
Re: Switching to 8MHz operation, what is in volved
« Reply #2 on: September 20, 2014, 03:38:42 PM »
Thanks for the prompt response Felix. 

I should have said that I would change out the crystal, I was thinking that would be the easy part.  not true?

I'll look into the clock prescale registers.

I've never liked the Arduino system of millis() and delay() very much so I don't care about breaking those.  For many  - or maybe all of my projects I have set up the timers myself.  This one is still using Timer0 and millis as usual but Timer2 is shut off and I am using the ICP on Timer1.  To use the ICP I had to modify the Moteino board by moving the chip select line from D8 to D7.  D8 is the only pin with that special function but it was easy to change.

Love this board so far!  I think this is going to be a really great platform.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6617
  • Country: us
    • LowPowerLab
Re: Switching to 8MHz operation, what is in volved
« Reply #3 on: September 20, 2014, 04:42:12 PM »
If you change the resonator to 8mhz your code will run half as fast (or 50% slower). You would need to recompile the bootloader and then compile your sketches for 8mhz.

Charly86

  • Jr. Member
  • **
  • Posts: 74
  • Country: fr
Re: Switching to 8MHz operation, what is in volved
« Reply #4 on: October 01, 2014, 05:38:47 AM »
themzlab

You can checkup this article, http://hallard.me/ulpnode-bootloader/ it explain how bootloader has been tweaked to achieve low power node and decrease the frequency to be able to run until 1.8V. My node are working at 4MHz but can switch them to 16MHz on demand.
Article was written in 2 parts, be prepared to have some reading.

Shimon

  • NewMember
  • *
  • Posts: 1
Re: Switching to 8MHz operation, what is in volved
« Reply #5 on: October 13, 2014, 01:19:52 AM »
What about internal 8 Mhz oscillation. ;D

Have anybody tried using RFM12B with atmega328 using internal 8 Mhz oscillator?

I am asking because i have used atmega328 many times without external oscillation for simple applications with no problems.

I wonder if it will be a problem with RFM12B/69.





« Last Edit: October 13, 2014, 01:23:02 AM by Shimon »

JRoode35

  • NewMember
  • *
  • Posts: 10
Re: Switching to 8MHz operation, what is in volved
« Reply #6 on: October 15, 2014, 03:52:11 PM »
I believe the SPI buss that the radios use to connect to the atmega needs a more accurate clock than the internal oscillator is. You should be able to replace the crystal with an 8mhz but you would have to burn a bootloader with the 8mhz fuse, you may be able to use the arduino pro mini 8mhz version. Also you would loose the ability to program wirelessly unless Felix made an 8Mhz version of his dual optiboot bootloader.

Justin