• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    C++
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A guide to best practices when using the Arduino IDE to program AVR microcontrollers

THE DOCUMENTS IN THIS DIRECTORY ARE ALL TO BE CONSIDERED DRAFTS I ASSUME ZERO RESPONSIBILITY FOR ISSUES RESULTING FROM FOLLOWING THIS ADVICE

Best Practices, Notes and Guidance

For programming AVRs with Arduino IDE(with some remarks on other IDEs)

Types of AVR boards

There are three types of AVR-based boards you may end up working with

  1. Basic - No bootloader, just the chip, any supporting components to provide extra functionality, and (hopefully) a convenient programming header (see below) to upload code These are often assembled with unprogrammed chips, and then programmed in circuit. Examples include the majority of commercial products, most ATTiny Classic parts, and the vast majority of modern AVRs (notable exceptions being the official Arduino boards).
  2. Bootloader based boards - These boards have a bootloader preloaded onto the chip. This enavbles programming through a different interface (usually a Serial port), and is very commonm in Arduino circles. Unless countermeasures have been taken aginst it, they can also be reprogramed through the basic method methioned above (though this may not be as convenient; for example, there may be no dedidated ISP header, forcing you to figure out which pin goes to each pin of the programmer). If the bootloader uses Serial is is likely based on Optiboot (and if not, it ought to be) though others exist, such as ChipBoot. Optiboot using boards usually have a mechanism to reset the chip when the DTR or RTS line is asserted (when the port is opened). a. Nano-like boards have a USB connector and serial adapter IC on them. DTR or RTS is tied to reset via a 0.1uF capacitor, which has a 10k external pullup to Vdd. b. Pro-mini-like boards have a 1x6 pin FTDI serial header on them for connection to the serial adapter and are generally the eqivalent of that
  3. VUSB Bootloader boards - technically a specific type of bootloader, VUSB/Micronucleus/Digispark uses a bitbanged "usb" implementation to upload. It works shockingly well considering how well (or rather how poorly) it conforms tothe USB standard. Despite that much working quite well - indeed well enough that you can ship a product with reset disabled, and still have people reliably upgrade the bootloader by uploading code ocontaining the new bootloader and pieece of code that copies it over the old version. However, it all comes unglued once the sketch starts. I have come to doubt the possibility
  4. Native USB boards - These have a microcontroller that interfaces directly to USB - like the classic 8u2, 16u2, 32u4 and so on. Unfortunately, thee is as yet no modern AVR with native USB. There is also a dark side to native USB - if your code hoses the app bad enough, it will only detect as a USB device for 8 seconds after plugging it in, until this is used to upload working code.

Types of chips and programing connections

  1. "Classic" avrs were released before 2016, have a good deal of similarity in how they work, and, as their native programming interface use the SPI pins, except that reset is driven low as if it were the SS pin on a typical SPI device. There are three ways to "soft-brick" these: a. Set the clock source to one that is not present. Sice the spec requires that the SCK period while programming be less than 1/3rd of the system clock, if the system clock is 0, ISP programming is impossible. b. Set the RSTDSBL fuse, which turns reset into a (really crappy) I/O pin. It has output drive srength of about 1/10th that of a normal pin in this mode. c. clear the SPIEN fuse, which disables SPI programming. The first case is easy to solve: Simply connect a ciock source that is within spend to the CLKI pin, and burn bootloader with thecorrect clock source selected. The other two can only be undones with an HV programer. One of these is vaguely, pratical to do with home-made tools. HVSP, for the 85, 84, and 841. All larger parts reqire HV-PP which can require up to 16 pins and is rarely if ever done in hobby circles.
  2. "Modern" AVRs are very reistant to bricking: a. Some parts allow reset UPDI to be used as GPIO. If this is done, an HV pulse is needed to reprogram them. b. During programming brown-out detect is forced on.
  3. Therefore, we do not advise setting PA0 to reset (instead of UPDI) or disabling reset on reset on any classic AVR. Especially one with more than 14 physical pins.

Sections

Glossary of terms

Status: Most important/relevant terms, I think, present. Covers terms used in this and other documents I've written about AVR parts for Arduino, as well as terms common in Arduino

Best Practices guide

Status: Mostly incomplete, some sections useful, many others absent or incomplete.

Hardware Notes

Status: Not organized or indexed, and not many items covered yet. Notes on specific hardware design decisions, one per file.

Troubleshooting Help

Status: Severely incomplete, not useful yet! Guidance for Arduino troubleshooting

Peripheral Guide

Status: Doesn't exist yet, some content written but elsewhere currently. A quick overview of various peripherals and accomplishing common tasks using them.

Project Planning

Status: Mostly not complete, some thoughts on part selection present. Choosing microcontroller and core, things like that

More Repositories

1

ATTinyCore

Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8
C
1,567
star
2

megaTinyCore

Arduino core for the tinyAVR 0/1/2-series - Ones's digit 2,4,5,7 (pincount, 8,14,20,24), tens digit 0, 1, or 2 (featureset), preceded by flash in kb. Library maintainers: porting help available!
C
549
star
3

DxCore

Arduino core for AVR DA, DB, DD, EA and future DU-series parts - Microchip's latest and greatest AVRs. Library maintainers: Porting help and adviccee is available.
C
180
star
4

AzzyAI

AzzyAI for Ragnarok Online
C#
30
star
5

arduino-tiny-841

Arduino core for ATtny841, 828, 1634 and 441
C
28
star
6

AzzyRF

433mhz OOK RF stuff for Arduino
C++
10
star
7

UsefulArduinoPosts

In
C
9
star
8

AVR_Research

"Late to bed and early to rise, work like hell and advertise." Wait, it's supposed to be *early* to bed? Oh dear. My score's not looking so great is it?
Python
8
star
9

LEDCTRLA

Simple Neopixel animation sketch for private event. Suitable as demonstration of Neopixel_Static library use.
C++
5
star
10

Adafruit_NeoPixel_Static

Adafruit w/out pinMode or malloc()/free() to save flash.
C++
5
star
11

tinyNeoPixel

tinyNeoPixel library - automatically included in core releases.
3
star
12

AVRProg

Objective: AVRProg.h library to include in Arduino sketch which will be able to program another AVR via ISP or UPDI
3
star
13

Adafruit_NeoPixel_PortA

Neopixel library for port A of AVR microcontrollers
C++
2
star
14

Adafruit_NeoPixel_Universal

Adafruit NeoPixel library with support for port A added.
C++
2
star
15

TinierGPS

TinyGPS, but with only GGA support, to save flash.
C++
2
star
16

ReleaseScripts

Board manager JSON + associated scripts
Shell
1
star
17

ProductInfo

Information on products from Azduino (formerly known as Azzy's Electronics)
1
star