Coder Social home page Coder Social logo

flaviohernan / megacore Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mcudude/megacore

0.0 2.0 0.0 1.42 MB

An Arduino core for the ATmega64 and ATmega128

License: Other

Makefile 2.05% C 27.36% Shell 0.07% C++ 58.14% Batchfile 0.01% Objective-C 1.16% Assembly 0.64% Arduino 10.57%

megacore's Introduction

MegaCore

An Arduino core for the ATmega64 and ATmega128, all running a modified version of Optiboot. 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.
This core requires at least Arduino IDE v1.6, where v1.6.5+ is recommended.
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 (File > Examples > AVR C code examples).

Table of contents

Supported microcontrollers:

  • ATmega128*
  • ATmega64*

(* All variants - A, L and so on)

Why add Arduino support for these microcontrollers?

  • They're dirt cheap (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)
  • They're been around for more than a decade, and can be found in a lot of different equipment
  • They got 53 IO pins (vs 32 for the MightyCore compatible ones and 86 for the ATmega1280/2560)

##Supported clock frequencies

  • 20 MHz external oscillator
  • 16 MHz external oscillator (default)
  • 12 MHz external oscillator
  • 8 MHz external oscillator
  • 8 MHz internal oscillator *
  • 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.
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.

* There might be some issues related to the internal oscillator. It's factory calibrated, but may be a little "off" depending on the calibration, ambient temperature and operating voltage. If uploading failes while using the 8 MHz internal oscillator you have three options:

  • Edit the baudrate line in the boards.txt file, and choose either 115200, 57600, 38400 or 19200 baud.
  • Upload the code using a programmer (USBasp, USBtinyISP etc.) or skip the bootloader
  • Use the 1 MHz option instead

##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. The ATmega64/128 haven't dedicated the BOD selection to extended fuse, so there's no way to only change the BOD option in the Arduino IDE. If you need to change this setting you'll have to edit the boards.txt file.

##Programmers MegaCore does not adds its own copies of all the standard programmers to the "Programmer" menu. Just select one of the stock programmers in the "Programmers" menu, and you're ready to "Burn Bootloader" or "Upload Using Programmer".

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.

##Write to own flash A while ago @majekw announced that he'd successfully modified the Optiboot bootloader 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.
With help from majek 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!
Please check out the Optiboot flasher example for more info about how this feature works, and how you can try it on your MegaCore compatible microcontroller.

##How to install ####Boards Manager Installation This installation method requires Arduino IDE version 1.6.4 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.
    • 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.

####Manual Installation Click on the "Download ZIP" button in the upper right corner. Exctract 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.

##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:

  • 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, and select ATmega64 or ATmega128.
  • 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.
  • 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. 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 the ATmega64/ATmega128! If you experience any issues related to bootloader burning or serial uploading, please use this forum post or create an issue on Github.

##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.
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 Since there are no standarized Arduino pinout for the ATmega64/128, 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 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. Click to enlarge:

##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.

megacore's People

Contributors

mcudude avatar per1234 avatar

Watchers

James Cloos avatar Flavio Hernan avatar

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.