This semester I am taking a course in microprocessors. We have been learning Atmel’s AVR 8-bit ISA.

(I just finished a report on the differences between ARM and AVR)

Check out the brand new kits that the school have been busy assembling:

Arduino Mega Two-line LCD, keypad (going to be an interrupt pain), LEDs, LDR, speaker, motor, what else?

Well it turns out that the manufacturing itself was done in China. I asked.

An experimental observation was that the board cannot handle 12V. I write “experimental observation” because I fried the first dev board and had to get it replaced. Fortunately there were spares 🙂 Note that the Arduino itself was not harmed in any form, as it could handle up to 20V.

I thought I’d blog a bit on what tools are available for writing assembly. (It’s that part of the semester again! Development tools… projects… labs… assignments…)

Debugging and simulation

AVR Studio is the best choice. Windows-only, so you’ll either have to boot Windows or virtualize. Both are fine.

  • If virtualizing with VirtualBox, make sure you follow this trick if you can’t get VirualBox to attach the board’s USB interface to the guest OS.
  • VMWare Fusion on Mac is happy happy happy.
  • VMWare Workstation on Linux? Never tried. Fedora updates include newer upstream kernels, for which the VMWare kernel modules don’t compile nicely without having to make a few patches.
  • OS X bootcamp is fine.

AVR Studio is free, but we’ve been using the older AVR Studio 4. It’s probably easier and more straightforward than using the latest and greatest ™.

If you want to explore other options apart from AVR Studio, um good luck..

[TODO: credit this] macsimavr (OS X), avra-atmega2560 (*nix)

Flashing hex files onto the AVR mega2560 without Windows

[For informational sake]

Just install avrdude from your package manager (apt-get/yum/brew) 🙂

If for some reason your distro’s repos doesn’t have avrdude, another source for a precompiled binary is the Arduino IDE package – download here.

e.g. /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude

Once you’ve done this, you probably want to write a handy shell script with all the parameters you need:

#!/bin/sh
# Arguments: <COM PORT> <HEX FILE>
#            e.g /dev/tty.usbmodem1461 flashingLEDs.hex
avrdude -C /Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -c wiring -p m2560 -P "{$1}" -b 115200 -U flash:w:"{$2}":i -D

(idk where does the conf file comes from if you didn’t have the Arduino package??)

Video

Unfortunately I didn’t get the startup sequence recorded – it briefly flashes “PANASONIC INVERTER”, which impressed the guy when we were presenting our project 🙂