Giter Club home page Giter Club logo

mcudude / megacore Goto Github PK

View Code? Open in Web Editor NEW
371.0 43.0 114.0 26.81 MB

Arduino hardware package for ATmega64, ATmega128, ATmega165, ATmega169, ATmega325, ATmega329, ATmega640, ATmega645, ATmega649, ATmega1280, ATmega1281, ATmega2560, ATmega2561, ATmega3250, ATmega3290, ATmega6450, ATmega6490, AT90CAN32, AT90CAN64 and AT90CAN128

License: Other

Makefile 6.66% C 39.72% Shell 16.80% C++ 36.36% Batchfile 0.01% Assembly 0.46%
arduino avr boards-manager atmega64 atmega128 atmega640 atmega1280 atmega1281 atmega2560 atmega2561

megacore's Introduction

MegaCore

Build Status MegaCore forum thread

An Arduino core for most 64 and 100-pin AVRs, all running the Urboot bootloader. This core requires at least Arduino IDE v1.8, where v1.8.9 or newer is recommended. IDE 2.x should also work.

From MegaCore version 3 and onwards, the Optiboot bootloader has been replaced by the superior Urboot bootloader. It's smaller, faster, and has automatic baud rate detection, and can read and write to EEPROM. Other cool features the bootloader provides but are not utilized by MegaCore are user program metadata stored in flash (that can easily be viewed by Avrdude -xshowall) and chip-erase functionality. If you already have Optiboot installed and don't want to replace it with Urboot, you can still upload programs without any compatibility issues. However, if you're burning a bootloader to a new chip, Urboot is the way to go.

Table of contents

Supported microcontrollers:

  • ATmega6490
  • ATmega6450
  • ATmega3290
  • ATmega3250
  • ATmega2561
  • ATmega2560
  • ATmega1281
  • ATmega1280
  • ATmega649
  • ATmega645
  • ATmega640
  • ATmega329
  • ATmega325
  • ATmega169
  • ATmega165
  • ATmega128
  • ATmega64
  • AT90CAN128
  • AT90CAN64
  • AT90CAN32

(All variants - A, L, P, PA, PV, V)

Can't decide what microcontroller to choose? Have a look at the specification table below:

Mega2560 Mega1280 Mega640 Mega2561 Mega1281 Mega128
CAN128
Mega6490
Mega6450
Mega64
CAN64
Mega649
Mega645
Mega6490
Mega6450
CAN32
Mega329
Mega325
Mega169
Mega165
Flash 256kB 128kB 64kB 256kB 128kB 128kB 64kB 64kB 32kB 32kB 16kB
RAM 8kB 8kB 8kB 8kB 8kB 4kB 4kB 4kB 2kB 2kB 1 kB
EEPROM 4kB 4kB 4kB 4kB 4kB 4kB 2kB 2kB 1kB 1kB 512B
IO pins 70/86 * 70/86 * 70/86 * 54 54 53 68 53 68 53 53
Serial ports 4 4 4 2 2 2 1 2 / 1 ** 1 2 / 1 ** 1
PWM pins 15 15 15 8 8 7 4 7 / 4 ** 4 7 / 4 ** 4
LED pin PB7 PB7 PB7 PB5 PB5 PB5 PB7 PB5 PB7 PB5 PB5

* Pin 70-85 is not broken out on the Arduino Mega. Make sure to check out the AVR style pinout for a more straightforward pinout.

** ATmega165/169/325/329/645/649 has one hardware serial port and four PWM outputs.

Supported clock frequencies

MegaCore supports a variety of different clock frequencies. Select the microcontroller in the boards menu, then select the clock frequency. You will have to hit "Burn bootloader" in order to set the correct fuses and upload the correct bootloader. This also has to be done if you want to change any of the fuse settings (BOD and EEPROM settings) regardless if a bootloader is installed or not.

Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time-critical operations, an external crystal/oscillator is recommended. The Urboot bootloader has automatic baud rate detection (except when using UART2 and UART3 on ATmega640/1280/2560), so UART uploads should work fine even though the oscillator is a little too fast or too slow.

Frequency Oscillator type Default upload speed
(bootloader has auto-baud)
Comment
16 MHz External crystal/oscillator 115200 Default clock on most AVR based Arduino boards
20 MHz External crystal/oscillator 115200
18.4320 MHz External crystal/oscillator 115200 Great clock for UART communication with no error
14.7456 MHz  External crystal/oscillator 115200 Great clock for UART communication with no error
12 MHz External crystal/oscillator 57600
11.0592 MHz External crystal/oscillator 115200 Great clock for UART communication with no error
8 MHz External crystal/oscillator 57600 Common clock when working with 3.3V
7.3728 MHz External crystal/oscillator 115200 Great clock for UART communication with no error
6 MHz External crystal/oscillator 57600
4 MHz External crystal/oscillator 9600
3.6864 MHz External crystal/oscillator 115200 Great clock for UART communication with no error
2 MHz External crystal/oscillator 9600
1.8432 MHz External crystal/oscillator 115200 Great clock for UART communication with no error
1 MHz External crystal/oscillator 9600
8 MHz Internal oscillator 38400 Might cause UART upload issues. See comment above
4 MHz Internal oscillator 9600 Derived from the 8 MHz internal oscillator
2 MHz Internal oscillator 9600 Derived from the 8 MHz internal oscillator
1 MHz Internal oscillator 9600 Derived from the 8 MHz internal oscillator

Bootloader option

MegaCore lets you select which serial port you want to use for uploading. UART0 is the default port for all targets, but any hardware serial port may be used. If your application doesn't need or require a bootloader for uploading you can also choose to disable it by selecting No bootloader. This frees 384 bytes of flash memory on ATmega165/169/325/3250/329/3290 and 512 bytes on ATmega64/128/645/6450/649/6490/1281/2560 and AT90CAN32/64/128.

Note that you need to connect a programmer and hit Burn bootloader if you want to change any of the Bootloader settings.

Baud rate option

Since Urboot has automatic baud rate detection, the upload baud rate can be changed without having to re-flash the bootloader. The default baud rate setting will pick a suited baud rate that also works with the legacy Optiboot bootloader used in earlier MegaCore versions. The other baud rate options may or may not work, depending on the clock frequency and accuracy of the clock source. A rule of thumb is that "non-round" baud rates like 230400 works best with "non-round" clock speeds like 18.4320 MHz, while "round" ones like 16 MHz work best with "round" baud rates like 250000.

BOD option

Brown-out detection, or BOD for short lets the microcontroller sense the input voltage and shut down if the voltage goes below the brown-out setting. To change the BOD settings you'll have to connect an ISP programmer and hit "Burn bootloader". Below is a table that shows the available BOD options:

ATmega640/1280/2560 ATmega1281/2561 ATmega3290/6490
ATmega3250/6450
ATmega165/169
ATmega325/329
ATmega645/649
ATmega64/128 AT90CAN32/64/128
4.3V 4.3V 4.3V 4.3V 4.0V 4.1V
2.7V 2.7V 2.7V 2.7V 2.7V 4.0V
1.8V 1.8V 1.8V 1.8V 3.9V
3.8V
2.7V
2.6V
2.5V
Disabled Disabled Disabled Disabled Disabled Disabled

EEPROM option

If you want the EEPROM to be erased every time you burn the bootloader or upload using a programmer, you can turn off this option. You'll have to connect an ISP programmer and hit "Burn bootloader" to enable or disable EEPROM retain. Note that when uploading using a bootloader, the EEPROM will always be retained.

Note that if you're using an ISP programmer or have the Urboot bootloader installed, data specified in the user program using the EEMEM attribute will be uploaded to EEPROM when you upload your program in Arduino IDE. This feature is not available when using the older Optiboot bootloader.

#include <avr/eeprom.h>

volatile const char ee_data EEMEM = {"Data that's loaded straight into EEPROM\n"};

void setup() {
}

void loop() {
}

Link time optimization / LTO

Link time optimization (LTO for short) optimizes the code at link time, usually making the code significantly smaller without affecting performance. You don't need to hit "Burn Bootloader" in order to enable or disable LTO. Simply choose your preferred option in the "Tools" menu, and your code is ready for compilation. If you want to read more about LTO and GCC flags in general, head over to the GNU GCC website!

Printf support

Unlike the official Arduino cores, MegaCore has printf support out of the box. If you're not familiar with printf you should probably read this first. It's added to the Print class and will work with all libraries that inherit Print. Printf is a standard C function that lets you format text much easier than using Arduino's built-in print and println. Note that this implementation of printf will NOT print floats or doubles. This is disabled by default to save space but can be enabled using a build flag if using PlatformIO.

If you're using a serial port, simply use Serial.printf("Milliseconds since start: %ld\n", millis());. You can also use the F() macro if you need to store the string in flash. Other libraries that inherit the Print class (and thus support printf) are the LiquidCrystal LCD library and the U8G2 graphical LCD library.

Pin macros

Note that you don't have to use the digital pin numbers to refer to the pins. You can also use some predefined macros that map "Arduino pins" to the port and port number:

// Use PIN_PE0 macro to refer to pin PE0 (Arduino pin 0)
digitalWrite(PIN_PE0, HIGH);

// Results in the exact same compiled code
digitalWrite(0, HIGH);

Write to own flash

MegaCore uses the excellent Urboot bootloader, written by Stefan Rueger. Urboot supports flash writing within the running application, meaning that content from e.g. a sensor can be stored in the flash memory directly without needing external memory. Flash memory is much faster than EEPROM, and can handle at least 10,000 write cycles before wear becomes an issue. For more information on how it works and how you can use this in your own application, check out the Serial_read_write for a simple proof-of-concept demo, and Flash_put_get + Flash_iterate for useful examples on how you can store strings, structs, and variables to flash and retrieve then afterward.

PROGMEM with flash sizes greater than 64kB

The usual PROGMEM attribute stores constant data such as string arrays to flash and is great if you want to preserve the precious RAM. However, PROGMEM will only store content in the lower section, from 0 and up to 64kB. If you want to store data in other sections, you can use PROGMEM1 (64 - 128kB), PROGMEM2 (128 - 192kB), or PROGMEM3 (192 - 256kB), depending on the chip you're using. Accessing this data is not as straightforward as with PROGMEM, but it's still doable:

const char far_away[] PROGMEM1 = "Hello from far away!\n"; // (64  - 128kB)
const char far_far_away[] PROGMEM2 = "Hello from far, far away!\n"; // (128 - 192kB)
const char far_far_far_away[] PROGMEM3 = "Hello from far, far, far away!\n"; // (192 - 256kB)

void print_progmem()
{
  uint8_t i;
  char c;

  // Print out far_away
  for(i = 0; i < sizeof(far_away); i++)
  {
    c = pgm_read_byte_far(pgm_get_far_address(far_away) + i);
    Serial.write(c);
  }

  // Print out far_far_away
  for(i = 0; i < sizeof(far_far_away); i++)
  {
    c = pgm_read_byte_far(pgm_get_far_address(far_far_away) + i);
    Serial.write(c);
  }
  // Print out far_far_far_away
  for(i = 0; i < sizeof(far_far_far_away); i++)
  {
    c = pgm_read_byte_far(pgm_get_far_address(far_far_far_away) + i);
    Serial.write(c);
  }
}

Programmers

Select your microcontroller in the boards menu, then select the clock frequency. You'll have to hit "Burn bootloader" in order to set the correct fuses and upload the correct bootloader.
Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time-critical operations, an external oscillator is recommended.

How to install

Boards Manager Installation

This installation method requires Arduino IDE version 1.8.0 or greater.

  • Open the Arduino IDE.
  • Open the File > Preferences menu item.
  • Enter the following URL in Additional Boards Manager URLs: https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json
  • Open the Tools > Board > Boards Manager... menu item.
  • Wait for the platform indexes to finish downloading.
  • Scroll down until you see the MegaCore entry and click on it.
  • Click Install.
  • After installation is complete close the Boards Manager window.

Manual Installation

Click on the "Download ZIP" button in the upper right corner. Extract the ZIP file, and move the extracted folder to the location "~/Documents/Arduino/hardware". Create the "hardware" folder if it doesn't exist. Open Arduino IDE, and a new category in the boards menu called "MegaCore" will show up.

Arduino CLI Installation

Run the following command in a terminal:

arduino-cli core install MegaCore:avr --additional-urls https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json

PlatformIO

PlatformIO is an open-source ecosystem for IoT and embedded systems, and supports MegaCore.

See PlatformIO.md for more information.

Getting started with MegaCore

  • Hook up your microcontroller as shown in the pinout diagram.
    • If you're not planning to use the bootloader (uploading code using a USB to serial adapter), the FTDI header and the 100 nF capacitor on the reset pin can be omitted.
  • Open the Tools > Board menu item, select MegaCore and select your preferred target.
  • If the BOD option is presented, you can select at what voltage the microcontroller will shut down at. Read more about BOD here.
  • Select your preferred clock frequency. 16 MHz is standard on most Arduino boards.
  • Select what kind of programmer you're using under the Programmers menu.
  • Hit Burn Bootloader. The LED pin will not toggle after the bootloader has been loaded.
  • Disconnect the ISP programmer, and connect a USB to serial adapter to the target microcontroller shown in the pinout diagram. Select the correct serial port under the Tools menu, and click the Upload button. If you're getting a timeout error, it may be because the RX and TX pins are swapped, or the auto-reset circuit isn't working properly (the 100 nF capacitor and a 10k resistor on the reset line).

Your code should now be running on the microcontroller!

Wiring reference

To extend this core's functionality a bit further, I've added a few missing Wiring functions to this hardware package. As many of you know Arduino is based on Wiring, but that doesn't mean the Wiring development isn't active. These functions are used as "regular" Arduino functions, and there's no need to include an external library.
I hope you find this useful because they really are!

Function list

  • portMode()
  • portRead()
  • portWrite()
  • sleepMode()
  • sleep()
  • noSleep()
  • enablePower()
  • disablePower()

For further information please view the Wiring reference page

Pinout

64-pin chips

MegaCore provides a standard, logical pinout for the 64-pin chips. The standard LED pin is assigned to digital pin 13/PIN_PB5.
Click to enlarge:

ATmega64/128/1281/2561
AT90CAN32/CAN64/CAN128
ATmega165/169/325/329/645/649

100-pin chips

MegaCore provides a standard, logical pinout for the 64-pin chips. The standard LED pin is assigned to digital pin 13/PIN_PB5. MegaCore includes the original Arduino Mega pinout for the ATmega640/1280/2560, but also a straightforward, "standard" pinout for all 100-pin chips. The standard LED pin is assigned to digital pin 13 on the Arduino MEGA pinout and digital pin 22 on the standard pinout (PIN_PB7 in both cases).
Click to enlarge:

ATmega640/1280/2560
Arduino MEGA pinout
ATmega640/1280/2560
"AVR" pinout
ATmega3250/3290/6450/6490

Minimal setup

Here are some simple schematics showing a minimal setup using an external crystal. Omit the crystal and the two 22pF capacitors if you're using the internal oscillator.
Click to enlarge:

ATmega64/128/1281/2561
AT90CAN32/CAN64/CAN128
ATmega165/325/645
ATmega169/329/649
ATmega640/1280/2560 ATmega3250/6450
ATmega3290/6490

megacore's People

Contributors

chepo92 avatar dewhisna avatar jackjan4 avatar mcudude avatar per1234 avatar spencekonde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

megacore's Issues

Macro errors with IRLib2

Not sure if this is an error in IRLib2's ifdefs or in the MegaCore support but when trying to even include in the library for the ATmega64a I run into these errors. I've gone through the IRLibe2 code and checked around for ifdefs that optionally include code for specific avr chips but didn't see anything that didn't have an else block that would skip including these. The define macros listed here all seem to be part of the Arduino framework so I'm confused as to why they wouldn't be included.

In file included from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:14:0:
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp: In member function 'void IRsendBase::enableIROut(uint8_t)':
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:286:34: error: 'TIMSK2' was not declared in this scope
  #define IR_RECV_DISABLE_INTR   (TIMSK2 = 0)
                                  ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:77:2: note: in expansion of macro 'IR_RECV_DISABLE_INTR'
  IR_RECV_DISABLE_INTR; //Timer2 Overflow Interrupt    
  ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:193:3: error: 'TCCR2A' was not declared in this scope
   TCCR2A = _BV(WGM20);  TCCR2B = _BV(WGM22) | _BV(CS20); \
   ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:80:2: note: in expansion of macro 'IR_SEND_CONFIG_KHZ'
  IR_SEND_CONFIG_KHZ(khz);
  ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:193:25: error: 'TCCR2B' was not declared in this scope
   TCCR2A = _BV(WGM20);  TCCR2B = _BV(WGM22) | _BV(CS20); \
                         ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:80:2: note: in expansion of macro 'IR_SEND_CONFIG_KHZ'
  IR_SEND_CONFIG_KHZ(khz);
  ^
In file included from /Users/joe/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /Users/joe/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/pgmspace.h:90,
                 from /Users/joe/Documents/Arduino/hardware/MegaCore/avr/cores/MegaCore/Arduino.h:28,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibProtocols.h:12,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.h:16,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:13:
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:193:38: error: 'WGM22' was not declared in this scope
   TCCR2A = _BV(WGM20);  TCCR2B = _BV(WGM22) | _BV(CS20); \
                                      ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:80:2: note: in expansion of macro 'IR_SEND_CONFIG_KHZ'
  IR_SEND_CONFIG_KHZ(khz);
  ^
In file included from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:14:0:
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:194:3: error: 'OCR2A' was not declared in this scope
   OCR2A = pwmval; OCR2B = pwmval / 3; })
   ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:80:2: note: in expansion of macro 'IR_SEND_CONFIG_KHZ'
  IR_SEND_CONFIG_KHZ(khz);
  ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:194:19: error: 'OCR2B' was not declared in this scope
   OCR2A = pwmval; OCR2B = pwmval / 3; })
                   ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:80:2: note: in expansion of macro 'IR_SEND_CONFIG_KHZ'
  IR_SEND_CONFIG_KHZ(khz);
  ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp: In member function 'void IRsendBase::mark(uint16_t)':
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:188:33: error: 'TCCR2A' was not declared in this scope
  #define IR_SEND_PWM_START     (TCCR2A |= _BV(COM2B1))
                                 ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:95:2: note: in expansion of macro 'IR_SEND_PWM_START'
  IR_SEND_PWM_START;
  ^
In file included from /Users/joe/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /Users/joe/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/pgmspace.h:90,
                 from /Users/joe/Documents/Arduino/hardware/MegaCore/avr/cores/MegaCore/Arduino.h:28,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibProtocols.h:12,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.h:16,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:13:
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:188:47: error: 'COM2B1' was not declared in this scope
  #define IR_SEND_PWM_START     (TCCR2A |= _BV(COM2B1))
                                               ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:95:2: note: in expansion of macro 'IR_SEND_PWM_START'
  IR_SEND_PWM_START;
  ^
In file included from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:14:0:
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp: In member function 'void IRsendBase::space(uint16_t)':
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:190:31: error: 'TCCR2A' was not declared in this scope
  #define IR_SEND_PWM_STOP    (TCCR2A &= ~(_BV(COM2B1)))
                               ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:101:2: note: in expansion of macro 'IR_SEND_PWM_STOP'
  IR_SEND_PWM_STOP;
  ^
In file included from /Users/joe/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/io.h:99:0,
                 from /Users/joe/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/include/avr/pgmspace.h:90,
                 from /Users/joe/Documents/Arduino/hardware/MegaCore/avr/cores/MegaCore/Arduino.h:28,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibProtocols.h:12,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.h:16,
                 from /Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:13:
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibHardware.h:190:47: error: 'COM2B1' was not declared in this scope
  #define IR_SEND_PWM_STOP    (TCCR2A &= ~(_BV(COM2B1)))
                                               ^
/Users/joe/Documents/Arduino/libraries/IRLibProtocols/IRLibSendBase.cpp:101:2: note: in expansion of macro 'IR_SEND_PWM_STOP'
  IR_SEND_PWM_STOP;
  ^
Using library LiquidCrystal at version 1.0.5 in folder: /Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal 
Using library EEPROM at version 2.0 in folder: /Users/joe/Documents/Arduino/hardware/MegaCore/avr/libraries/EEPROM 
Using library IRLibRecvPCI in folder: /Users/joe/Documents/Arduino/libraries/IRLibRecvPCI (legacy)
Using library IRLib2 in folder: /Users/joe/Documents/Arduino/libraries/IRLib2 (legacy)
Using library IRLibProtocols in folder: /Users/joe/Documents/Arduino/libraries/IRLibProtocols (legacy)
exit status 1
Error compiling for board ATmega64.

Is ATMegaS128 supported?

Will I be able to use the MegaCORE in Arduino IDE for the ATMegaS128? Noob here, worried about ATMegaS128 running off 3.3V instead of ATMega128's 5.0V. I intend to attach a 8MHz with your MegaCORE minimal setup wiring. Thanks for the help! Pls delete this thread if i posted in the wrong place.

Old ATmega128 board blinky doesn't work on arduino compile

Hi,

I have this weird problem, when i compile a simple blinky program using Arduino and Megacore Atmega128. I can't get the LED to blink at all, however, a simple C program compiled in avr-gcc will make it blink. Here is my Arduino code.

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(PORTB0, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(PORTB0, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(PORTB0, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

and here is my c code.

/*

  • $Id: hw.c,v 1.1 2010/10/19 05:18:47 bsd Exp $

*/

/*

  • HW - Hello World
  • This is a very simple project designed only to familiarize oneself
  • with the use of a Makefile, the compiler, linker, and FLASH
  • download tool (such as AVRDUDE) when working with the MAVRIC /
  • MAVRIC-II board.
  • This program simply blinks the on-board LED on and off, once per
  • second. It demonstrates setting up a periodic timer interrupt as a
  • time keeping source, the use of declaring and using an interrupt
  • handler with AVR-GCC, and toggling a PORT output line.
  • See: http://www.bdmicro.com/
  • Configuration:
  • MAVRIC - ensure that DIPSW 9 is "on".
  • MAVRIC-II - ensure that jumper LEDEN is installed
  • */

#include <avr/io.h>
#include <avr/interrupt.h>

#include <inttypes.h>

volatile uint16_t ms_count;

/*

  • ms_sleep() - delay for specified number of milliseconds
    */
    void ms_sleep(uint16_t ms)
    {
    TCNT0 = 0;
    ms_count = 0;
    while (ms_count != ms)
    ;
    }

/*

  • millisecond counter interrupt vector
    */
    SIGNAL(TIMER0_COMP_vect)
    {
    ms_count++;
    }

/*

  • initialize timer 0 to generate an interrupt every millisecond.
    /
    void init_timer(void)
    {
    /
    • Initialize timer0 to generate an output compare interrupt, and
    • set the output compare register so that we get that interrupt
    • every millisecond.
      /
      TIFR |= _BV(OCIE0);
      TCCR0 = _BV(WGM01)|_BV(CS02)|_BV(CS00); /
      CTC, prescale = 128 /
      TCNT0 = 0;
      TIMSK |= _BV(OCIE0); /
      enable output compare interrupt /
      OCR0 = 125; /
      match in 1 ms */
      }

int main(void)
{
init_timer();

/* enable interrupts */
sei();

DDRB = 0x01; /* enable PORTB 1 as an output */

while (1) {
ms_sleep(512); /* wait 0.5 seconds /
PORTB ^= 0x01; /
toggle LED */
}

}

What do I need to change in the MegaCore for this old board that will compile the code and execute the code correctly?

I am using avrdude + usbasp to upload the code in both instances.

Unable to see any output in the Serial monitor

Hi,
I have been able to successfully burn the boot loader onto Atmega128 and then upload sketch to it as well.
Sketch works, as one would expect it to.
I am using USBTinyISP as the programmer.
But when I try to check the serial output, I am unable to.

(It's possible I am missing something here, Serial doesn't go really with ISP, no TX, RX pins there ).

Thanks.

I2C pind don't match Datasheet

Hi I've only looked at your arduino pin map for the 64 pin avr. I've noticed that the pins for the I2C communication don't match the data sheet.

MegaCore/avr/variants/64-pin-avr/pins_arduino.h

lines 79 & 80

static const uint8_t SDA = 18;
static const uint8_t SCL = 19;

i think should read

static const uint8_t SDA = 19;
static const uint8_t SCL = 18;

Atmega2560V, trying to burn bootloaders

Hello,
I am trying to burn MegaCore bootloaders to it, I have setup my custom PCB with Atmega2560V-8AU and 8Mhz Crystal + Load Caps all assembled on using PCBA process.
I am trying to burn MegaCore bootloaders to it, I am using Arduino UNO as ISP Programmer. My connections are all correct, It shows different Device Signatures (see below) whenever I hit Burn Bootloaders....

0x0000ff
0x00003f
0x0000ff
0x00ff00
0x001000
0xff0000
0xfc0000
0x00fe00

This is complete output with different Device Signatures

Arduino: 1.8.3 (Windows 10), Board: "ATmega2560, Arduino MEGA pinout, 2.7v, Disabled (default), 8 MHz external"

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-avr-100-pin\avr/avrdude.conf -v -patmega2560 -cstk500v1 -PCOM4 -b19200 -e -Ulock:w:0x3f:m -Uefuse:w:0xfd:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xf7:m

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-avr-100-pin\avr/avrdude.conf"

     Using Port                    : COM4
     Using Programmer              : stk500v1
     Overriding Baud Rate          : 19200
     AVR Part                      : ATmega2560
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
       flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x00fe00
avrdude: Expected signature for ATmega2560 is 1E 98 01
Double check chip, or use -F to override this check.

avrdude done. Thank you.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

What should be the problem.??? How to solve this.?

Verification Error on Burning Bootloader

Hi.
I'm getting following Error on burning bootloader using arduino ide:
avrdude: verifying ... avrdude: verification error, first mismatch at byte 0xfd00 0xff != 0x09 avrdude: verification error; content mismatch

I get this error on both Atmega64a and Atmega128a using any clock config and any programmer.

Timers of Atmega128

I have a new problem.
I try to use TimerOne lib.
It's perfectly working with Atmega328 (as SnoozeLib). But I have a next Errors on MegaCore:
"was not declared in this scope" for regiters TIMSK1, GTCCR and for PSRSYNC.
If I change TIMSK1->TIMSK - it accepted by compiler. (but I understand that it is no right way).

My goal is to use your sleep() and noSlip() with timer interrupt and hardware interrupt for wakeUp of CPU.
Help me please what I have todo for it.

or may be You can to recommend some onother sleep/timer library what will compitable with MegaCore.

Thanks so much.

Consider merging avr-100-pin branch into master

I've been working with the ATmega648/1280/2560 implementation for a while now, and other improvements like subtrees for the bootloader and core files have also been added. I'm sure the avr-100-pinbrach still contains some bugs, but I'll have to merge it into the master branch in order to get it properly tested. I think it's a good idea to wait with a boards manager release until the dust have settled and (potentially) ugly bugs have been squashed.

@per1234 if you want to create a PR to avr-100-pin and add Travis to MegaCore, I'd happily merge that. Now that this core is getting more and more complex in terms of dependencies, incorporating Travis seems to be a good idea. Any thoughts?

Compile problem

I just installed Arduino 1.6.4 IDE (on WinXP) and MegaCore. I selected Board: "ATmega128", Clock: "16MHz external", Port: "COM1" and am using Programmer: "USBasp" (I already successfully installed the bootloader.).

When trying to compile the "BareMinimum" example the respective compile fails:

'ld.exe has encountered a problem and needs to close. ...'

last console message is:

'N:\Program Files\ArduinoWindows\arduino-1.6.4\hardware\tools\avr/bin/avr-ar rcs n:\Temp\build8835498005943340668.tmp/core.a n:\Temp\build8835498005943340668.tmp\WString.cpp.o
N:\Program Files\ArduinoWindows\arduino-1.6.4\hardware\tools\avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega128 -o n:\Temp\build8835498005943340668.tmp/BareMinimum.cpp.elf n:\Temp\build8835498005943340668.tmp\BareMinimum.cpp.o n:\Temp\build8835498005943340668.tmp/core.a -Ln:\Temp\build8835498005943340668.tmp -lm
collect2.exe: error: ld returned 5 exit status
Error compiling.'

However other examples like "AnalogReadSerial" do successfully compile. I don't know if the compile problem only affects the empty "BareMinimum" example or if the underlying root cause might also surface in other cases.

Interrupts

Use the rfm69. Also a problem with interrupts. I have used pin4. Put the number of interrupts 4, but transfer no. What could be the problem?

#define RFM69_CS 8
#define RFM69_IRQ 4 //pin
#define RFM69_IRQN 4// ?

RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, true, RFM69_IRQN);

Checked! Only works 6 interrupt! Why? What am I doing wrong? How to use pin 4?

Installation of MegaCore

I wanted to do the manual install of the avr-100-pin branch but I don't have a ~/Documents/Arduino directory.

I do have:

~/.arduino
~/.arduino15/packages/arduino/hardware/
~/.arduino-create/

Any suggestions?

Thanks,
Bob

Problems with intrrupts on atmega128

Hi
Firstly Thank you for you hardwork supplying this repository to everyone.

Im having problems compiling GRBL for the ATmega128. and I am wondering if you can help.

I can compile GRBL on ATmega2561, ATmega128, ATmega2560, Atmega1280 and ATmega640 but when I try to compile it on the ATmega128 (and on the ATmega64) I keep getting the same error.

I'm using GRBL1.1f (https://github.com/gnea/grbl) but I have also tried using a few other versions. I'm using arduino 1.8.1 on windows 10 and arduino 1.8.3 on Linux mint and keep getting the same error.

I think the issue is relating to the intrrupt in the core rather than the GRBL software. I've spent several days now googling for and trying to get an answer but still to no luck.

Any help would be greatfully receaved. Thank you

The output from the arduino IDE is:

In file included from C:\Users\X\Documents\Arduino\libraries\grbl\grbl.h:47:0,
from C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:22:
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c: In function 'limits_init':
C:\Users\X\Documents\Arduino\libraries\grbl\cpu_map.h:73:28: error: 'PCMSK0' undeclared (first use in this function)
#define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:44:5: note: in expansion of macro 'LIMIT_PCMSK'
LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
^
C:\Users\X\Documents\Arduino\libraries\grbl\cpu_map.h:73:28: note: each undeclared identifier is reported only once for each function it appears in
#define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:44:5: note: in expansion of macro 'LIMIT_PCMSK'
LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:45:5: error: 'PCICR' undeclared (first use in this function)
PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
^
In file included from C:\Users\X\Documents\Arduino\libraries\grbl\grbl.h:47:0,
from C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:22:
C:\Users\X\Documents\Arduino\libraries\grbl\cpu_map.h:71:28: error: 'PCIE0' undeclared (first use in this function)
#define LIMIT_INT PCIE0 // Pin change interrupt enable pin
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:45:20: note: in expansion of macro 'LIMIT_INT'
PCICR |= (1 << LIMIT_INT); // Enable Pin Change Interrupt
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c: In function 'limits_disable':
C:\Users\X\Documents\Arduino\libraries\grbl\cpu_map.h:73:28: error: 'PCMSK0' undeclared (first use in this function)
#define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:61:3: note: in expansion of macro 'LIMIT_PCMSK'
LIMIT_PCMSK &= ~LIMIT_MASK; // Disable specific pins of the Pin Change Interrupt
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:62:3: error: 'PCICR' undeclared (first use in this function)
PCICR &= ~(1 << LIMIT_INT); // Disable Pin Change Interrupt
^
In file included from C:\Users\X\Documents\Arduino\libraries\grbl\grbl.h:47:0,
from C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:22:
C:\Users\X\Documents\Arduino\libraries\grbl\cpu_map.h:71:28: error: 'PCIE0' undeclared (first use in this function)
#define LIMIT_INT PCIE0 // Pin change interrupt enable pin
^
C:\Users\X\Documents\Arduino\libraries\grbl\limits.c:62:19: note: in expansion of macro 'LIMIT_INT'
PCICR &= ~(1 << LIMIT_INT); // Disable Pin Change Interrupt
^
exit status 1
Error compiling for board ATmega128.

building bootstraps fail for branch 100-pin

I tried executing ./makeall on optiboot_flash_256kb directory and got the following output:
errors.txt

I tried building a single bootstrap with just "make atmega2561" selecting the defaults. Which seems to woirk:
avr-gcc (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Error=2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega2561 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -c -o optiboot_flash.o optiboot_flash.c
optiboot_flash.c:288:6: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
#warning BAUD_RATE error greater than 2%
^
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega2561 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -Wl,--section-start=.text=0x3fc00 -Wl,--section-start=.version=0x3fffe -Wl,--relax -nostartfiles -nostdlib -o atmega2561/optiboot_flash_atmega2561__.elf optiboot_flash.o -lc
avr-size atmega2561/optiboot_flash_atmega2561__.elf
text data bss dec hex filename
666 0 0 666 29a atmega2561/optiboot_flash_atmega2561__.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex atmega2561/optiboot_flash_atmega2561__.elf atmega2561/optiboot_flash_atmega2561__.hex
avr-objdump -h -S atmega2561/optiboot_flash_atmega2561__.elf > atmega2561

But produces truncated files:

optiboot_flash_atmega2561__.hex.txt
optiboot_flash_atmega2561__.lst.txt

I had arduino version 1.6.9 installed, but building inside of the hardware directory where magacore was installed issuing a which avr-gcc gives /usr/bin/avr-gcc, whch may be a ubuntu package.

Incorrect prescaler values in Tone.cpp

Hi, first of of all, thank you for providing this software and instruction, after quite a bit of searching and frustration it has helped me to get my ATmega128 board to run with Arduino.

I realize tone() is not on your list of supported functions, but just in case anyone tries, here's what I've found. In file Tone.cpp, lines 267 ff. the timer prescaler value is determined. Now, on ATmega128, only timer 0 has prescalers 32 and 128, while the other three timers have only 1/8/64/256/1024 (see datasheet).
So the code needs to be rewritten, in particular:

  • Remove distinction between 8- and 16-bit timers (line 268), following code should work for both.
  • Lines 277 and 288 should be changed to if (_timer == 0... to account for the additional values.
  • The values in the conditional expressions in lines 286, 297 and 302 are switched around.

I've tried this with timer 2 (which is assigned by default) and the toneMelody example works as expected (it didn't before). Making the above changes may break the code for other processors (I've no idea how many different prescalers exist), so a general solution would require a bit of research in the datasheets.

Thanks and best regards
Wolfgang

rfm69

Connected rfm69 using the library https://github.com/LowPowerLab/RFM69
The problem with the definition of Interrupt. pin 4 is what is the interrupt number?

#define RFM69_CS 8
#define RFM69_IRQ 4 //pin
#define RFM69_IRQN 4// ?

RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, true, RFM69_IRQN);

Wrong high-fuses

I think that the high-fuses have an incorrect value (0xc6) for ATmega128 in file boards.txt. Correct value is 0xc4, because the bootloader is downloaded to address 0xfc00.

Can't allow INT for WD

Hello,

Cant allow int for WD timer.

WDTCR |= _BV(WDIE);

compilator says:'WDIE' was not declared in this scope.

On atmega328 its working: WDTCSR |= _BV(WDIE);

Help me please...

Facing problems in uploading bootloader to Atmega128A

{{ I already opened a thread at https://forum.arduino.cc/index.php?topic=425844.0 but then realized this might be the better place... }}

Hi,
I followed the exact circuit as noted https://camo.githubusercontent.com/b6046ccf5b261d6accdf030c2158ddb119f898d8/687474703a2f2f692e696d6775722e636f6d2f5549696e6f38492e706e67

But I get errors (or simply time out) while uploading.
I tried uploading the bootloader using a genuine Arduino Uno as SPI programmer. And just to experiment, I tried uploading bootloader using a USB to TTL serial connection.

No luck so far.

Is there any specific programmer that is known to work? There are conflicting notes on USBTiny. Seems it is better than USBasp but only works for Atmega64... Or I am just reading too much and not putting things in correct order?

Any inputs will be greatly appreciated.

Thanks.

delay() function

When I call delay(100000UL) function it waits only 1 second.
_delay_ms() function does not have problem.
This issue is not tested in real hardware enviroment, it occurs in Proteus simulation.

Eclipse

I just tried to use the MegaCore in http://eclipse.baeyens.it/ but it seems that either the respective Eclipse plugin just sucks or there is some incompatibility/problem with the MegaCore.

At first it seems as if the Eclipse/Arduino plugin correctly detects the MegaCore config. It presents the right processor selection and generates a respective "ATmega128" project. Unfortunately the generated "Includes" list is incomplete and it only contains the "core" and "variant" folders but none of the standard includes that SHOULD also be in that list.

Any ideas if this might rather be caused by the MegaCore config or by the Eclipse plugin?

standard pin mapping

I want to use an ATmega128 as an upgrade for my existing ProMini328 based circuit and am trying to get the respective pin mapping right (so as to reuse my existing code with minimal changes): According to your pinout graph I am inclined to think that PF4 corresponds to Arduino analog A4 but the graph also suggests that the hardware SDA pin is PD1 - my existing Arduino ProMini code expects that A4 and SDA is actually the same pin. (similarilly there is a mismatch between the SS,SCK,MOSI,MISO pins and the standard Arduino digital pin assignment, e.g. MOSI=D11 not D10). Finally, what pins are the Arduino digital pins 2-7 mapped to: PE2-PE7?

Thanks for your help

error in "MegaCore minimal setup" graph

From what I see VCC pins are 52+21 and GND pins are 53+22. The two 100nF capacitor related comments therefore refer to the wrong pins, e.g. "Place as close to pin 20 and 21 as possible" should read "Place as close to pin 21 and 22 as possible", etc,_

Sketch destroing Bootloader.

Dear Sirs,

Thanks for great Job.
But I have one problem.
I using UNO as ISP for burning Bootloader. All works great.
But After first uploading of any sketch by USB-adapter(FTDI) - I have no more bootloader on Atmega128.
I use ARDUINO_USB_LIGHT - adapter. I have cap. 0.1 beetween RESETS (adapter-atmega). For my projects on Atmega328 - a have't this problems.
How I can resolve this situation?

Hope on Your help.
Thanks.

Power-on Reset isn't working.?

As you know i am working on a project for elite sports for which i am using Atmega2560V and megaCore bootloaders..

while developing, I have observed that Power-on Reset isn't working, I have to manually pull reset pin to low to reset the Atmega2560V.

I am powering up chip with a single cell LIPO battery which is supplied then to 3.3V power booster and voltage regulator, I am using this boardhttps://www.sparkfun.com/products/retired/11231

Blink_using_Timer example not updated?

Hi, I just ran into the incorrect bit value assignment in this example, which you fixed sometime in November. However, I only installed Arduino a few days ago, and the problem is still there. Is it possible that the fix somehow didn't make it from github to the automatic installation?

Regards, Wolfgang

Interrupt not working

Have some code that I prototyped on an Arduino Uno and Mega2560. It works fine on those platforms but when I move the code over it doesn't work. The issue is that an interrupt attached to pin 4 never fires.

The hardware is setup to pull the pin high and pressing a button will bring it low. I've verified this is actually happening by attaching an oscilloscope and checking the waveform. I'm also able to switch the code to do a digitalRead instead and that works correctly, it's only the interrupt that doesn't fire. The relevant code is:

#define TRIGGER_PIN 4

pinMode(TRIGGER_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(TRIGGER_PIN), triggerPress, LOW);

Bootloader boot time faster than expected

This is more a question than a problem.

I previously used MightyCore with Atmega324 and 16MHz external oscillator. After burning bootloader, LED flashed twice per second as per readme. Time taken by bootloader between reset and start of program execution was 1.5s (consistent with an Arduino).

Now I am using MegaCore with Atmega64A and 16MHz external oscillator. After burning the bootloader, I saw the LED flash much faster and (I think) it was not regular. Bootloader works OK, programs loaded via serial run OK and millis() based timing is correct.

However, I have measured how long the bootloader takes between reset and start of program. It is much shorter, under 240ms.

Is this an expected difference between MegaCore and MightCore?

Thanks

analogReference(EXTERNAL)

analogReference(EXTERNAL);

However, the "EXTERNAL" is not what we understand the external reference voltage, but AVCC.
My circuit uses an external reference voltage, and it is so set, but I found that my reference voltage is wrong, but I can not find my circuit and components have any problems, this problem plagued me a long time, and finally found The result of this setting is to connect the AVCC to the VREF Pin, so there will be such a problem.

image

Also, the reference voltage on the Mega128 DataSheet is set such that the REFS register is set to "11" to be the internal reference, but it is "10" in your file, but it also seems to work properly.

I recommend:
     DEFAULT -> AVCC
     INTERNAL -> Internal 2.56V Voltage Reference
     EXTERNAL -> True external connection for reference voltage
Do you see if this is feasible?

How about full atmega640,1280,2560 support?

I know that two of these are 'supported' as the arduino mega board. However, this board ignores over a dozen i/o pins, and there is no support for the atmega640 part. It should be easy enough to add an i/o map that enables full use of all pins on these parts, and to add support for the '640 variant.

I'll look into this myself eventually, but thought I'd mention it incase someone else wants to pick up this gauntlet.

digitalPinToInterrupt() issue

see pins_arduino.h:
#define digitalPinToInterrupt(p) (((p) >= 4 && (p) <= 7) ? (p) : ((p) >= 18 && (p) <= 21) ? (p) - 18 : NOT_AN_INTERRUPT)

shouldn't it rather be:

#define digitalPinToInterrupt(p) (((p) >= 3 && (p) <= 6) ? (p+1) : ((p) >= 18 && (p) <= 21) ? (p) - 18 : NOT_AN_INTERRUPT)

out of range address 0x200000

hi everyone i try to upload the bootloader on atmega64, i make the minimal board with 16Mhz cristal, an external 5v power supply, modify the fuses on board.txt to up to 4k space for bootloader and use an arduino uno as isp, but when try to upload i have this issue..

avrdude: ERROR: address 0x20000 out of range at line 40 of C:\Users.......10/bootloaders/optiboot/atmega64/optiboot_atmega64_16MHz.hex

someone can help to me please? thanks

verification error, first mismatch at byte 0x3fc00

Hello there,
I am trying to burn bootloaders to my Atmega2560V-8AU but came up with this error, what is this suppose to be.? how to solve this one .

Arduino: 1.6.13 (Mac OS X), Board: "ATmega2560, Arduino MEGA pinout, 2.7v, Disabled (default), 8 MHz internal"

/Users/mudassir/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino8/bin/avrdude -C/Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/avrdude.conf -v -patmega2560 -cstk500v1 -P/dev/cu.usbmodem1421 -b19200 -e -Ulock:w:0x3f:m -Uefuse:w:0xfd:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xe2:m

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:32:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/avrdude.conf"
     User configuration file is "/Users/mudassir/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/cu.usbmodem1421
     Using Programmer              : stk500v1
     Overriding Baud Rate          : 19200
     AVR Part                      : ATmega2560
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
       flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

/Users/mudassir/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino8/bin/avrdude -C/Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/avrdude.conf -v -patmega2560 -cstk500v1 -P/dev/cu.usbmodem1421 -b19200 -Uflash:w:/Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex:i -Ulock:w:0x0f:m

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:32:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/avrdude.conf"
     User configuration file is "/Users/mudassir/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/cu.usbmodem1421
     Using Programmer              : stk500v1
     Overriding Baud Rate          : 19200

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xfd:
avrdude: load data efuse data from input file 0xfd:
avrdude: input file 0xfd contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xd6"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd6:
avrdude: load data hfuse data from input file 0xd6:
avrdude: input file 0xd6 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xe2"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xe2:
avrdude: load data lfuse data from input file 0xe2:
avrdude: input file 0xe2 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done. Thank you.

     AVR Part                      : ATmega2560
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
       flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex"
avrdude: writing flash (262144 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 262144 bytes of flash written
avrdude: verifying flash memory against /Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex:
avrdude: load data flash data from input file /Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex:
avrdude: input file /Users/mudassir/Documents/Arduino/hardware/MegaCore-avr-100-pin 2/avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex contains 262144 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x3fc00
0x00 != 0x01
avrdude: verification error; content mismatch

avrdude done. Thank you.

Error while burning bootloader.

1 Byte of Lock verified..

Hello sorry to disturb you again, I was trying to boot load my another Atmega2560V, supplied 1Mhz to the XTAL1 and used -F to override the signature check, Now I can upload bootloaders to the chip.

But the output shows 1Byte of Lock verified.

Here is the complete output.

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -F -CC:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/avrdude.conf -v -patmega2560 -cstk500v1 -PCOM4 -b19200 -e -Ulock:w:0x3f:m -Uefuse:w:0xfd:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xe2:m

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/avrdude.conf"

     Using Port                    : COM4
     Using Programmer              : stk500v1
     Overriding Baud Rate          : 19200
     AVR Part                      : ATmega2560
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
       flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9803
avrdude: Expected signature for ATmega2560 is 1E 98 01
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xfd:
avrdude: load data efuse data from input file 0xfd:
avrdude: input file 0xfd contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xd6"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd6:
avrdude: load data hfuse data from input file 0xd6:
avrdude: input file 0xd6 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xe2"
avrdude: writing lfuse (1 bytes):

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -F -CC:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/avrdude.conf -v -patmega2560 -cstk500v1 -PCOM4 -b19200 -Uflash:w:C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex:i -Ulock:w:0x0f:m
Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xe2:
avrdude: load data lfuse data from input file 0xe2:
avrdude: input file 0xe2 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done. Thank you.

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/avrdude.conf"

     Using Port                    : COM4
     Using Programmer              : stk500v1
     Overriding Baud Rate          : 19200
     AVR Part                      : ATmega2560
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
       flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9803
avrdude: Expected signature for ATmega2560 is 1E 98 01
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex"
avrdude: writing flash (262144 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 262144 bytes of flash written
avrdude: verifying flash memory against C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex:
avrdude: load data flash data from input file C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex:
avrdude: input file C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-master\avr/bootloaders/optiboot_flash/atmega2560/optiboot_flash_atmega2560_38400_8000000L.hex contains 262144 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% -0.00s

avrdude: verifying ...
avrdude: 262144 bytes of flash verified
avrdude: reading input file "0x0f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0f:
avrdude: load data lock data from input file 0x0f:
avrdude: input file 0x0f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done. Thank you.

I am really sorry to disturb you again.

I hope you reply.

Thank you

verification error; content mismatch

Gives this error when uploading codes using arduino IDE with USBASP, and when PORTE is used in the code, the code will not upload at all. but It uploads fine using the hex file generated in arduino IDE directly via avrdude.

avrdude: verifying ... avrdude: verification error, first mismatch at byte 0x0100 0xff != 0x20 avrdude: verification error; content mismatch

bad.txt
good.txt

Error on compiling bootloader with -DBIGBOOT

make atmega128
avr-gcc (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Error=2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -c -o optiboot_flash.o optiboot_flash.c
optiboot_flash.c:311:2: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
#warning BAUD_RATE error greater than 2%
^
optiboot_flash.c: In function ‘main’:
optiboot_flash.c:502:93: warning: backslash and newline separated by space
#if defined(AVR_ATmega8515) || defined(AVR_ATmega8535) || defined(AVR_ATmega16) \
^
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -Wl,--relax -nostartfiles -nostdlib -o atmega128/optiboot_flash_atmega128__.elf optiboot_flash.o -lc
optiboot_flash.o: In function appStart': /home/drw/Software/builder/MegaCore/avr/bootloaders/optiboot_flash/optiboot_flash.c:942: undefined reference to eeprom_write_byte'
/home/drw/Software/builder/MegaCore/avr/bootloaders/optiboot_flash/optiboot_flash.c:942: undefined reference to `eeprom_read_byte'
collect2: error: ld returned 1 exit status
Makefile:614: recipe for target 'atmega128/optiboot_flash_atmega128__.elf' failed
make: *** [atmega128/optiboot_flash_atmega128__.elf] Error 1

SPI question

what is the reason for the "strange" interrupt mask mapping?
#elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
#define SPI_INT0_MASK (1<<INT4)
#define SPI_INT1_MASK (1<<INT5)
#define SPI_INT2_MASK (1<<INT0)
#define SPI_INT3_MASK (1<<INT1)
#define SPI_INT4_MASK (1<<INT2)
#define SPI_INT5_MASK (1<<INT3)
#define SPI_INT6_MASK (1<<INT6)
#define SPI_INT7_MASK (1<<INT7)

Verification error after loading code by Serial

Hi! I'm building my project on Atmega128 chip using your bootloader. Bootloader was load properly by USBASP and I even can see it in FLASH through Avrdude terminal mode from address 0xFC00 (as I remember). Then I faced an issue during loading my program by Serial through USB-UART (CH340 chip). It seems that Arduino IDE connects to Atmega and I see Avrdude writing progress bars but then it fails on verification step:

avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x0c
avrdude: verification error; content mismatch

It seems that my sketch code was not recorded to Atmega... If I loading the code through programmer by ICSP - it works well.
Here is the Avrdude log:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Users/dmitrij/Library/Arduino15/packages/MegaCore/hardware/avr/2.0.0/avrdude.conf -v -patmega128 -carduino -P/dev/cu.wchusbserial1420 -b115200 -D -Uflash:w:/var/folders/18/60_7xyc92138x6vhc69t25zc0000gn/T/arduino_build_113404/Blink.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/Users/dmitrij/Library/Arduino15/packages/MegaCore/hardware/avr/2.0.0/avrdude.conf"
     User configuration file is "/Users/dmitrij/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/cu.wchusbserial1420
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200
     AVR Part                      : ATmega128
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom         4    12    64    0 no       4096    8      0  9000  9000 0xff 0xff
       flash         33     6   128    0 yes    131072  256    512  4500  4500 0xff 0xff
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : Arduino
     Description     : Arduino
     Hardware Version: 3
     Firmware Version: 6.2
     Vtarget         : 0.3 V
     Varef           : 0.3 V
     Oscillator      : 28.800 kHz
     SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9702 (probably m128)
avrdude: reading input file "/var/folders/18/60_7xyc92138x6vhc69t25zc0000gn/T/arduino_build_113404/Blink.ino.hex"
avrdude: writing flash (1240 bytes):

Writing | ################################################## | 100% 0.34s

avrdude: 1240 bytes of flash written
avrdude: verifying flash memory against /var/folders/18/60_7xyc92138x6vhc69t25zc0000gn/T/arduino_build_113404/Blink.ino.hex:
avrdude: load data flash data from input file /var/folders/18/60_7xyc92138x6vhc69t25zc0000gn/T/arduino_build_113404/Blink.ino.hex:
avrdude: input file /var/folders/18/60_7xyc92138x6vhc69t25zc0000gn/T/arduino_build_113404/Blink.ino.hex contains 1240 bytes
avrdude: reading on-chip flash data:

Reading | ########################################Произошла ошибка при загрузке скетча
########## | 100% 0.34s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x0c
avrdude: verification error; content mismatch

avrdude done. Thank you.

Do you have any thoughts on it?

TIMER1_A_PIN and TIMSK1 not declared in this scope

I make DMD sketch with #include DMD.h, TimerOne.h, SPI.h, Wire.h, RTClib.h and DHT.h, but the error messages appears.
What should I do ?

Arduino: 1.8.4 (Windows 7), Board: "ATmega128, 2.7v, Disabled (default), 8 MHz external"

In file included from C:\Users\myfolder\Documents\Arduino\Dot Matrix\test128\test128.ino:10:0:
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h: In member function 'void TimerOne::setPwmDuty(char, unsigned int)':
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:236:13: error: 'TIMER1_A_PIN' was not declared in this scope
if (pin == TIMER1_A_PIN) OCR1A = dutyCycle;
^
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h: In member function 'void TimerOne::pwm(char, unsigned int)':
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:245:13: error: 'TIMER1_A_PIN' was not declared in this scope
if (pin == TIMER1_A_PIN) { pinMode(TIMER1_A_PIN, OUTPUT); TCCR1A |= _BV(COM1A1); }
^
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h: In member function 'void TimerOne::disablePwm(char)':
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:260:13: error: 'TIMER1_A_PIN' was not declared in this scope
if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);
^
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h: In member function 'void TimerOne::attachInterrupt(void (*)())':
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:274:2: error: 'TIMSK1' was not declared in this scope
TIMSK1 = _BV(TOIE1); //atmega128 only TIMSK
^
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h: In member function 'void TimerOne::detachInterrupt()':
C:\Users\myfolder\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:281:2: error: 'TIMSK1' was not declared in this scope
TIMSK1 = 0; //atmega128 only TIMSK
^
exit status 1
Error compiling for board ATmega128.

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Default Cristal 16Mhz

If you choose, 16Mhz to ATMEGA64 Arduino IDE, looks that is wrong, because on PROTEUS a delay of 1000 is too short! delay(1000);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.