New York Tech Journal
Tech news from the Big Apple

#AVR from scratch and how to program them

Posted on January 22nd, 2016

#HackManhattan

01/21/2016 @ Hack Manhattan, 137 West 14th St, NY

20160121_181347[1] 20160121_181725[1] 20160121_182043[1] 20160121_182248[1]

Guan Yang spoke about AVR microcontrollers and how to program them. He talked about the large family of ATxmeg processors. The most powerful (such as the ATmeg328P) are used to power the #Arduino with the following adaptations:

  1. Translate usb to serial
  2. Bootloader
  3. “Operating system” – for timers
  4. IDE and compiler

But, there are others in the family that are less expensive with the following characteristics:

  1. Use debugWire – not an advantage
  2. More optimized code
  3. direct use of timers and other peripherals

but Guan noted that the Arduino is available for many chips include ATtiny85 and AVRs are expensive relative to performance.

He next talked about the ATtiny85A which is smaller and cheaper than processors on the Arduino board. It has a 10 bit ADC – 8 single-end channels; universal serial interface (USI) and only supports one protocol at a time. It receives power over pin 1 with ground on pin 14.

Fuses, which are 3 bytes of non-volatile memory, control things like the clock source and divider; brownout detection; bootloader parameters. Modern microcontrollers often don’t have fuses. http://www.embedded.com/ contains documentation on fuses.

There are several Atmel programming interfaces. Guan concentrated on SPI.

One needs to program in assembler or C with avr-gcc being the main compiler he uses. He shows a “hello world” program using the DDRA (data direction register) to turn on a bit for port A.

DDRA |= _BV(0)

He compiled the code using the Avrdude programmer.

Atmel studio is an IDE adapted for Visual Studio and he also uses CrossPack as a dev environment for Atmel’s AVRs.

Debugging is done using single wire protocol over the reset pin.

AvaRICE is a programs with interfaces with GNU debugger. The debugger allows you to set breakpoints and stop execution to view registers.

He recommended using one set of pins for programming and other for operations, but there are a limited number of pins and this may not be possible.

He noted that if you order from Digi-key, they will custom program your processor for a small fee.

He uses a Segger j-link to program AVRs. It also supports a variety of ARMs

He concluded, by again noting that AVRs are cheap, but the price of ARMs has dropped, so the price advantage of AVRs is evaporating, but they still might hold advantages in particular situations (#InternetOfThings).

posted in:  Hack Manhattan, hardware, Internet of Things, Programming    / leave comments:   No comments yet