Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge avr-100-pin branch into master #49

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
bc4d88e
Add ATmega640/1280/2560
MCUdude Mar 28, 2017
5002f19
Fix formatting
MCUdude Mar 28, 2017
a3ba3ff
Update README.md
MCUdude Mar 28, 2017
e546d43
Add 640/1280/2560 support
MCUdude Mar 29, 2017
9727293
Delete SPI.h
MCUdude Apr 6, 2017
275469d
Delete SPI.cpp
MCUdude Apr 6, 2017
c391bc9
fix structure
MCUdude Apr 7, 2017
1dc72d5
fix interrupts
MCUdude Apr 7, 2017
3c30966
Initial commit
MCUdude Apr 7, 2017
cd5ce21
First preliminary version
MCUdude Apr 7, 2017
ac381d3
Fix multiple pinouts issue
MCUdude Apr 7, 2017
c6ae0fd
Fix analogReference issue
MCUdude Apr 7, 2017
e4ad487
Add 640/1280/2560 support
MCUdude Apr 7, 2017
dcab604
Fix missing endif
MCUdude Apr 7, 2017
a3783f1
Fix typo
MCUdude Apr 8, 2017
51999de
fix formatting
MCUdude Apr 8, 2017
7c4675b
Add 640/1280/2560 support
MCUdude Apr 8, 2017
f7da4c6
Update library
MCUdude Apr 8, 2017
26b7334
Fix missing 640 compability
MCUdude Apr 8, 2017
83bcfea
Fix formatting
MCUdude Apr 8, 2017
e04eb5e
Add 640/1280/2560 support
MCUdude Apr 8, 2017
6489e31
Merge all optiboot copies from all my cores into one
MCUdude Apr 23, 2017
e17b24a
Update boards.txt
MCUdude Apr 23, 2017
ea3d1ec
Rename variants
MCUdude Apr 23, 2017
4555cd1
Create README.md
MCUdude Apr 23, 2017
fde355a
remove local bootloader
MCUdude Apr 23, 2017
6a9beda
Add optiboot_flash as submodule
MCUdude Apr 23, 2017
d685f11
delete submodule
MCUdude Apr 24, 2017
a1cfb17
Squashed 'avr/bootloaders/optiboot_flash/' content from commit ab5e765
MCUdude Apr 24, 2017
74f6443
Merge commit 'a1cfb17ea516cc376b3fa3f0100fb57094d1c776' as 'avr/bootl…
MCUdude Apr 24, 2017
8f43b64
Squashed 'avr/bootloaders/optiboot_flash/' changes from ab5e765..201b586
MCUdude Apr 24, 2017
5cd289d
Add build information
MCUdude Apr 24, 2017
c869016
add analogPinToChannel macro
MCUdude Apr 25, 2017
9a30680
Move EXTERNAL_NUM_INTERRUPTS macro
MCUdude Apr 30, 2017
5910b0e
Change core path
MCUdude Apr 30, 2017
382231f
Squashed 'avr/cores/MCUdude_corefiles/' content from commit 7d73be6
MCUdude Apr 30, 2017
4fb85d2
Merge commit '382231f3ff54a027d90ae3c091eedc471c33e914' as 'avr/cores…
MCUdude Apr 30, 2017
6db5332
Update macros
MCUdude Apr 30, 2017
07cf253
remove old files
MCUdude May 1, 2017
81128ca
Update minimal setup schematics
MCUdude May 7, 2017
33eb4da
Fix errors
MCUdude May 8, 2017
d1e5a8c
Add arduino-ci-script repository at e6c1b9b as a subtree
per1234 May 13, 2017
039be8e
Use Travis CI for automated testing
per1234 May 7, 2017
f569fdb
Merge pull request #42 from per1234/travis-ci
MCUdude May 13, 2017
c563018
Move build badge
MCUdude May 13, 2017
d60c221
Move build script
MCUdude May 13, 2017
f21b75f
Fix digitalPinToPCICR macro
MCUdude May 13, 2017
5495125
Add PCINT related macros
MCUdude May 14, 2017
b86d35c
Bump version
MCUdude May 14, 2017
1f30e82
Change badge path
MCUdude May 14, 2017
0240436
Update arduino-ci-script subtree to 27f2438
per1234 May 15, 2017
0e31f8f
Merge pull request #43 from per1234/update_arduino-ci-script
MCUdude May 16, 2017
131ab02
Update arduino-ci-script subtree to 6ec96b8
per1234 May 17, 2017
608792b
Remove unnecessary check_success call from .travis.yml
per1234 May 17, 2017
40acbf2
Merge pull request #45 from per1234/update_arduino-ci-script
MCUdude May 18, 2017
c51b5d1
Update arduino-ci-script subtree to dc0c81d
per1234 May 18, 2017
cf04d9b
Update arduino-ci-script subtree to 7fd36de
per1234 May 19, 2017
7c023ff
Merge pull request #47 from per1234/update_arduino-ci-script
MCUdude May 19, 2017
11fac20
Update README.md
MCUdude May 20, 2017
fada33d
Add leading zeros to the report folder name
per1234 May 20, 2017
5a9460b
Merge pull request #48 from per1234/report-folder-leading-zeros
MCUdude May 20, 2017
0485272
Add ATmega640/1280/2560
MCUdude May 20, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
423 changes: 423 additions & 0 deletions .travis.yml

Large diffs are not rendered by default.

84 changes: 44 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# MegaCore
An Arduino core for the ATmega64, ATmega128, ATmega1281 and ATmega2561, all running a [modified version of Optiboot](#write-to-own-flash). Major libraries such as SD, Servo, SPI and Wire are modified to work with this core. Still, a large amount of third-party libraries often works without any modifications. <br/>
# MegaCore
[![Build Status](https://travis-ci.org/MCUdude/MegaCore.svg?branch=master)](https://travis-ci.org/MCUdude/MegaCore) [![MegaCore forum thread](https://img.shields.io/badge/support-forum-blue.svg)](https://forum.arduino.cc/index.php?topic=386733.0)

An Arduino core for ATmega64, ATmega128, ATmega640, ATmega1280, ATmega1281, ATmega2560 and ATmega2561, all running a [custom version of Optiboot](#write-to-own-flash). Major libraries such as SD, Servo, SPI and Wire are modified to work with this core. Still, a large amount of third-party libraries often works without any modifications. <br/>
This core requires at least Arduino IDE v1.6, where v1.6.12+ is recommended. <br/>
If you're into "pure" AVR programming, I'm happy to tell you that all relevant keywords are being highlighted by the IDE through a separate keywords file. Make sure to test the [example files](https://github.com/MCUdude/MegaCore/tree/master/avr/libraries/AVR_examples/examples) (File > Examples > AVR C code examples).
If you're into "pure" AVR programming, I'm happy to tell you that all relevant keywords are being highlighted by the IDE through a separate keywords file. Make sure to check out the [example files](https://github.com/MCUdude/MegaCore/tree/master/avr/libraries/AVR_examples/examples) (File > Examples > AVR C code examples).


# Table of contents
Expand All @@ -10,7 +12,6 @@ If you're into "pure" AVR programming, I'm happy to tell you that all relevant k
* [BOD option](#bod-option)
* [Link time optimization / LTO](#link-time-optimization--lto)
* [Programmers](#programmers)
* [Why add Arduino support for these microcontrollers?](#why-add-arduino-support-for-these-microcontrollers)
* [Write to own flash](#write-to-own-flash)
* **[How to install](#how-to-install)**
- [Boards Manager Installation](#boards-manager-installation)
Expand All @@ -23,27 +24,27 @@ If you're into "pure" AVR programming, I'm happy to tell you that all relevant k

## Supported microcontrollers:
* ATmega2561
* ATmega2560
* ATmega1281
* ATmega1280
* ATmega640
* ATmega128
* ATmega64

(All variants - A, L, V)
<br/> <br/>
Can't decide what microcontroller to choose? Have a look at the specification table below:

| | ATmega2561 | ATmega1281 |ATmega128 | ATmega64 |
|--------------|------------|------------|----------|----------|
| **Flash** | 256kB | 128kB | 128kB | 64kB |
| **RAM** | 8kB | 8kB | 4kB | 4kB |
| **EEPROM** | 4kB | 4kB | 4kB | 2kB |
| **IO pins** | 54 | 54 | 53 | 53 |
| **PWM pins** | 8 | 8 | 7 | 7 |

| | Mega2560 | Mega1280 | Mega640 | Mega2561 | Mega1281 | Mega128 | Mega64 |
|--------------|----------|----------|---------|----------|----------|---------|--------|
| **Flash** | 256kB | 128kB | 64kB | 128kB | 128kB | 128kB | 64kB |
| **RAM** | 8kB | 8kB | 8kB | 8kB | 8kB | 4kB | 4kB |
| **EEPROM** | 4kB | 4kB | 4kB | 4kB | 4kB | 4kB | 2kB |
| **IO pins** | 70/86 * | 70/86 * | 70/86 * | 54 | 54 | 53 | 53 |
| **PWM pins** | 15 | 15 | 15 | 8 | 8 | 7 | 7 |
| **LED pin** | PB7 | PB7 | PB7 | PB5 | PB5 | PB5 | PB5 |

## Why add Arduino support for these microcontrollers?
* They're dirt cheap (ATmega64/128 can be bought for less than a dollar at AliExpress and Ebay)
* They're still hand solderable (The TQFP variant have 0.8mm pin pitch)
* 53/54 IO pins (vs 32 for the [MightyCore](https://github.com/MCUdude/MightyCore) compatible ones and 86 for the ATmega1280/2560)
<b>*</b> 86 IO pins is only available with the [*AVR pinout*](#atmega64012802560) selected


## Supported clock frequencies
Expand All @@ -56,7 +57,7 @@ Can't decide what microcontroller to choose? Have a look at the specification ta
* 1 MHz internal oscillator

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. <br/>
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.
Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time critical applications an external oscillator is recommended.
</br></br>

<b>*</b> When using the 18.432 MHz option (or any frequency by which 64 cannot be divided evenly), micros() is 4-5 times slower (~110 clocks). It reports the time at the point when it was called, not the end.
Expand All @@ -74,12 +75,12 @@ millis() is not affected, only micros() and delay(). Micros() executes equally f
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:
<br/>

| ATmega2561 | ATmega1281 | ATmega128 | Atmega64 |
|------------|------------|------------|-----------|
| 4.3v | 4.3v | 4.3v | 4.3v |
| 2.7v | 2.7v | 2.7v | 2.7v |
| 1.8v | 1.8v | - | - |
| Disabled | Disabled | Disabled | Disabled |
| Mega2560 | Mega1280 | Mega640 | Mega2561 | Mega1281 | Mega128 | Mega64 |
|----------|----------|----------|----------|----------|----------|---------|
| 4.3v | 4.3v | 4.3v | 4.3v | 4.3v | 4.3v | 4.3v |
| 2.7v | 2.7v | 2.7v | 2.7v | 2.7v | 2.7v | 2.7v |
| 1.8v | 1.8v | 1.8v | 1.8v | 1.8v | - | - |
| Disabled | Disabled | Disabled | Disabled | Disabled | Disabled | Disabled|


## Link time optimization / LTO
Expand All @@ -95,10 +96,9 @@ Make sure you connect an ISP programmer, and select the correct one in the "Prog


## Write to own flash
A while ago [@majekw](https://github.com/majekw) announced that he'd [successfully modified the Optiboot bootloader](http://forum.arduino.cc/index.php?topic=332191.0) to let the running program permanently store content in the flash memory.
The flash memory is much faster than the EEPROM, and can handle about 10 000 write cycles. <br/>
With help from [majek](https://github.com/MCUdude/MegaCore/issues/6) this feature is working perfectly with the MegaCore! To enable this feature the bootloader needs to be replaced by the new one. Simply hit "Burn Bootloader", and it's done! <br/>
Please check out the [Optiboot flasher example](https://github.com/MCUdude/MegaCore/blob/9793029aea382b41fc5dd81aa8af909fbf244026/avr/libraries/Optiboot_flasher/examples/SerialReadWrite/SerialReadWrite.ino) for more info about how this feature works, and how you can try it on your MegaCore compatible microcontroller.
MegaCore implements [@majekw's fork of Optiboot](https://github.com/majekw/optiboot), which enables flash writing functionality within the running application. This means that content from e.g. a sensor can be stored in the flash memory directly, without the need of externa memory. Flash memory is much faster than EEPROM, and can handle about 10 000 write cycles.

Please check out the [Optiboot flasher example](https://github.com/MCUdude/MegaCore/blob/9793029aea382b41fc5dd81aa8af909fbf244026/avr/libraries/Optiboot_flasher/examples/SerialReadWrite/SerialReadWrite.ino) for more info about how this feature works, and how you can use it with your MegaCore compatible microcontroller.


## How to install
Expand All @@ -110,7 +110,6 @@ This installation method requires Arduino IDE version 1.6.4 or greater.
* 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.
* **Note**: If you are using Arduino IDE 1.6.6 then you may need to close **Boards Manager** and then reopen it before the **MegaCore** entry will appear.
* Click **Install**.
* After installation is complete close the **Boards Manager** window.

Expand All @@ -120,22 +119,21 @@ Open Arduino IDE, and a new category in the boards menu called "MegaCore" will s


## Getting started with MegaCore
Ok, so you're downloaded and installed MegaCore, but do I get the wheels spinning? Here's a quick start guide:
Ok, so you're downloaded and installed MegaCore, but how to get started? Here's a quick start guide:
* Hook up your microcontroller as shown in the [pinout diagram](#pinout).
- 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, and select **ATmega64**, **ATmega128**, **ATmega1281** or **ATmega2561**.
* Open the **Tools > Board** menu item, and select **ATmega64**, **ATmega128**, **ATmega1281**, **ATmega2561**, **ATmega640**, **ATmega1280** or **ATmega2560**.
* Select your prefered 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**. If an LED is connected to pin PB5, it should flash twice every second.
* Hit **Burn Bootloader**. If an LED is connected to pin PB5/PB7, it should flash twice every second.
* Now that the correct fuse settings is sat and the bootloader burnt, you can upload your code in two ways:
- Disconnect your programmer tool, and connect a USB to serial adapter to the microcontroller, like shown in the [pinout diagram](#pinout). Then select the correct serial port under the **Tools** menu, and click the **Upload** button. If you're getting some kind of timeout error, it means your RX and TX pins are swapped, or your auto reset circuity isn't working properly (the 100 nF capacitor on the reset line).
- Keep your programmer connected, and hold down the `shift` button while clicking **Upload**. This will erase the bootloader and upload your code using the programmer tool.

Your code should now be running on your microcontroller! If you experience any issues related to bootloader burning or serial uploading, please use *[this forum post](https://forum.arduino.cc/index.php?topic=386733.0)* or create an issue on Github.

Your code should now be running on the microcontroller!

## Wiring reference
To extend this core's functionality a bit futher, I've added a few missing Wiring functions. As many of you know Arduino is based on Wiring, but that doesn't mean the Wiring development isnt active. These functions is used as "regular" Arduino functions, and there's no need to include an external library.<br/>
To extend this core's functionality a bit futher, 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 is used as "regular" Arduino functions, and there's no need to include an external library.<br/>
I hope you find this useful, because they really are!

### Function list
Expand All @@ -152,12 +150,18 @@ I hope you find this useful, because they really are!


## Pinout
Since there are no standarized Arduino pinout for the ATmega64/128/1281/2561, I decided to create my own. I've tried to make it as simple and logical as possible. This pinout makes great sense if you're buying this [cheap breakout boards](http://www.ebay.com/itm/381547311629) at Ebay or AliExpress (just make sure to remove C3 in order to get auto reset working). The standard LED pin is assigned to Arduino pin 13 (PB5), and will blink twice if you hit the reset button.
<b>Click to enlarge:</b>
</br> </br>
<img src="http://i.imgur.com/zwCXyHA.jpg" width="800">

### ATmega64/128/1281/2561
Since there are no standarized Arduino pinout for the ATmega64/128/1281/2561, I've created one. I've tried to make it as simple and logical as possible. This pinout makes great sense if you're buying this [cheap breakout boards](http://www.ebay.com/itm/381547311629) at Ebay or AliExpress (just make sure to remove C3 in order to get auto reset working). The standard LED pin is assigned to Arduino pin 13, and will blink twice if you hit the reset button.

### ATmega640/1280/2560
Beside including the original Arduino Mega pinout for the ATmega640/1280/2560, I've also added an *AVR pinout*, which is a more straight forward and logical pinout if you're not working with the Arduino Mega board. For the default Arduino Mega pinout, the standard LED pin is assigned to Arduino pin 13, and for the AVR pin it's assigned to pin 22.
<b>Click to enlarge:</b> <br/>
<img src="http://i.imgur.com/ez5MyvI.jpg" width="280"> <img src="http://i.imgur.com/k00WGLk.jpg" width="280"> <img src="http://i.imgur.com/DfR7arD.jpg" width="280">



## Minimal setup
Here is a simple schematic showing a minimal setup using an external crystal. Skip the crystal and the two 22pF capacitors if you're using the internal oscillator. <br/> **There have been reported issues when trying to burn the bootloader. If you experience such issues, try adding a 1k resistor in series with pin PE0 and PE1.**
<img src="http://i.imgur.com/UIino8I.png" width="750">
Here's some simple schematics for the ATmega64/128/1281/2561 and ATmega640/1280/2560 showing a minimal setup using an external crystal. Omit the crystal and the two 22pF capacitors if you're using the internal oscillator. <br/>
<b>Click to enlarge:</b> <br/>
<img src="http://i.imgur.com/lYzdULi.png" width="400"> <img src="http://i.imgur.com/gQS1ORv.png" width="400">
Loading