LowPowerLab Forum

Hardware support => Moteino => Topic started by: davegravy on May 18, 2016, 05:40:44 PM

Title: timing using 8Mhz
Post by: davegravy on May 18, 2016, 05:40:44 PM
I've switched my node from default config to 8Mhz internal oscillator. Gateway is still on 16Mhz external (moteino default).

When transmitting from node to gateway using SendWithRetry() , acks are no longer received with no timeout specified (I think it defaults to 50ms?). I've needed to double the timeout to 100ms, but this seems backwards since a single clock cycle now corresponds to more time on the node. I should be able to half it to 25ms, right?

At least with the listenmode example sketch, I needed to half the sleep times below to get the "woke" message to return to the gateway in time.

    if (from) {
      while (burstRemaining > 0) {
        LowPower.powerDown(SLEEP_60MS, ADC_OFF, BOD_OFF);
        burstRemaining -= 60;
      }
      LowPower.powerDown(SLEEP_30MS, ADC_OFF, BOD_OFF);
      radio.send(from, "woke", 4);
    }
Title: Re: timing using 8Mhz
Post by: Felix on May 19, 2016, 01:27:10 PM
If you did everything right, I'd expect the time to be respected in code, Xms to be Xms and not multiples or halves.
I think part of this change involves making your code compile for 8mhz instead of 16mhz, ie altering your boards.txt as mentioned in other threads realating to running @ 8mhz.
Title: Re: timing using 8Mhz
Post by: davegravy on May 19, 2016, 02:23:32 PM
Quote from: Felix on May 19, 2016, 01:27:10 PM
If you did everything right, I'd expect the time to be respected in code, Xms to be Xms and not multiples or halves.
I think part of this change involves making your code compile for 8mhz instead of 16mhz, ie altering your boards.txt as mentioned in other threads realating to running @ 8mhz.

I double checked and I do have the right frequency specified in boards.txt.

##############################################################
Moteino8mhz.name=Moteino8mhz
Moteino8mhz.upload.tool=arduino:avrdude
Moteino8mhz.upload.protocol=arduino
Moteino8mhz.upload.maximum_size=31744
Moteino8mhz.upload.speed=57600
Moteino8mhz.bootloader.low_fuses=0xD2
Moteino8mhz.bootloader.high_fuses=0xDC
Moteino8mhz.bootloader.extended_fuses=0xFE
Moteino8mhz.bootloader.path=optiboot
Moteino8mhz.bootloader.file=optiboot_atmega328_8mhz.hex
Moteino8mhz.bootloader.unlock_bits=0x3F
Moteino8mhz.bootloader.lock_bits=0xCF
Moteino8mhz.build.mcu=atmega328p
Moteino8mhz.build.f_cpu=8000000L
Moteino8mhz.build.core=arduino:arduino
Moteino8mhz.build.variant=arduino:standard
Moteino8mhz.build.board=AVR_MOTEINO
##############################################################


Just to clarify - if I don't make the burst-remaining timing change, the gateway thinks there was no response and that the wake attempt failed.
Title: Re: timing using 8Mhz
Post by: Felix on May 19, 2016, 03:53:29 PM
Ok so how exactly did you switch to 8mhz internal RC?
Title: Re: timing using 8Mhz
Post by: davegravy on May 19, 2016, 10:14:46 PM
Used the adafruit guide to turn my raspberry pi into a programmer (gpio pins + avrdude command lines) https://learn.adafruit.com/program-an-avr-or-arduino-using-raspberry-pi-gpio-pins/overview (https://learn.adafruit.com/program-an-avr-or-arduino-using-raspberry-pi-gpio-pins/overview) Set fuses per what's in the boards.txt above.

Recompiled your boatloader using 8mhz and 57600 baud compile options... Then I burned it.
Title: Re: timing using 8Mhz
Post by: Felix on May 20, 2016, 08:11:05 AM
What happens if you program your new 8mhz board with a 1 second ON/OFF blink? Does it blink for 1 second?
Title: Re: timing using 8Mhz
Post by: davegravy on May 21, 2016, 12:05:24 AM
Why didn't I think of that?   :P

And yes,  it is flashing at 1s... Which now baffles me as to why the listenmode example has stopped working...  It was working fine when I was running the node off the 16mhz external oscillator.