Go Down

Topic: MegaCore - Arduino support for ATmega64/128/1281/2561 and ATmega640/1280/2560 (Read 15636 times) previous topic - next topic

scharkalvin

I had an idea for  a mod to the bootloader.
When operating the chip at 1.8-3.3 volts it's usually necessary to lower the clock frequency by half.
There is a fuse setting that divides the xtal clock (but not by 2).   So if I'm using a mega644 at 3.3 volts, and I have a 20mhz crystal in there, we could set the fuse to divide the clock frequency (by 4 or 8 ), and then in the bootloader, reset the divider to 2.  This in case we don't have a 10mhz clock.

Oh, also we'd need to add 10mhz to the list of cpu clock frequencies for those processors that can use it.

westfw

Optiboot, if you compile it from source, supports any clock rate that you care to give it.

The fuses only permit "full speed" or "divide by 8."
It's not clear that the oscillator is spec'ed to work at full speed at low voltage; frequently when "overclocking" CPUs in general, the oscillator is the first thing to stop working (and you use an external clock generator instead.)

I think you could set the fuses for divide-by-8 and configure the bootloader for 20MHz/8, and then reset CLKPR in the beginning of your sketch to get 5 or 10MHz...


talamascool

In order to get the IRremote library to work, you'll have to manually download and install the library. You can get it from here. Click the green "clone or download" button.
hello i've tried to upload this code to an attiny2313 @8mhz internal clock.

#include <IRremote.h>

const int pin=4;
const int led=9;
int toggle=0;
IRrecv irrecv(pin);
decode_results results;

void setup() {
irrecv.enableIRIn();
pinMode(led,OUTPUT);

}

void loop() {
  if(irrecv.decode(&results)){
    if(results.value==0x1000C||0xC||0x17AB7F3E){
    if(toggle==0){
      digitalWrite(led,HIGH);
      toggle=1;
    }
    else{
      digitalWrite(led,LOW);
      toggle=0;
    }   
  }
  irrecv.resume();
}

}

pretty simple really, just trying something.

it will give me a lot of errors in the verbose, they're so many that i think is rude to post them all, but i can do if needed. but the errors look mostly like this.

G:\arduino\libraries\IRremote\boarddefs.h:217:29: error: 'WGM22' was not declared in this scope

  TCCR2B               = _BV(WGM22) | _BV(CS20); \

                             ^

G:\arduino\libraries\IRremote\irSend.cpp:119:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'

  TIMER_CONFIG_KHZ(khz);

  ^

G:\arduino\libraries\IRremote\boarddefs.h:217:42: error: 'CS20' was not declared in this scope

  TCCR2B               = _BV(WGM22) | _BV(CS20); \

                                          ^

G:\arduino\libraries\IRremote\irSend.cpp:119:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'

  TIMER_CONFIG_KHZ(khz);

  ^

In file included from G:\arduino\libraries\IRremote\IRremoteInt.h:111:0,

                 from G:\arduino\libraries\IRremote\IRremote.h:24,

                 from G:\arduino\libraries\IRremote\irSend.cpp:1:

G:\arduino\libraries\IRremote\boarddefs.h:218:2: error: 'OCR2A' was not declared in this scope

  OCR2A                = pwmval; \

  ^

G:\arduino\libraries\IRremote\irSend.cpp:119:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'

  TIMER_CONFIG_KHZ(khz);

  ^

G:\arduino\libraries\IRremote\boarddefs.h:219:2: error: 'OCR2B' was not declared in this scope

  OCR2B                = pwmval / 3; \

  ^

G:\arduino\libraries\IRremote\irSend.cpp:119:2: note: in expansion of macro 'TIMER_CONFIG_KHZ'

  TIMER_CONFIG_KHZ(khz);

  ^

i have the feeling that the attiny is not compatible with the library.


Go Up