DaveWiki | Edit | RecentChanges | Preferences | All Pages | lyons42
Difference (from prior major revision)
(no other diffs)
Changed: 35c35
* On July 12, I got an ATxmega128A1 to blink an LED. It comes in a TQFP100 package, so I used a $1.50 adapter board from FuturLec to bring the pins out to .1" headers.
|
* On 12-Jul-2009, I got an ATxmega128A1 to blink an LED. It comes in a TQFP100 package, so I used a $1.50 adapter board from FuturLec to bring the pins out to .1" headers.
|
Getting started with AVR Microcontrollers on Mac OS X
- I took EvilMadScientist's TechShop class, "Choosing a Microcontroller", which pointed me in a good direction. The instructor had his MacBookPro set up to do AVR work using the free avr-gcc toolchain, and I got some of the same equipment he was using.
- From http://www.DigiKey.com/ - AVRISPmkII programmer (~$35) — USB to computer, 6-pin ISP cable to your AVR circuit
- AVR chips: Handy models in DIP packages include ATtiny2313, ATmega168, ATmega328.
- EvilMadScientist - minimal target boards for ATtiny2313, ATmegaXX8.
- Toolchain - Get "CrossPack-AVR"
- (Historical: I compiled pieces of the gcc toolchain myself, following Leah B's instructions. It would have been easier to download OSX-AVR at the time, but now CrossPack-AVR is the cool new thing.)
- There is a lot of good information in the avr-libc manual (it's not at all limited to C topics). Just skip over the places where there is page-after-page of unexciting macro definitions (int16_t, int_least_16_t, uint16_t, uint_least_16t, uint_fast16_t, etc), and the rest of it is meaty. For example, you'll want to know the stuff from avr/io.h, avr/delay.h, avr/power.h, avr/sleep.h, and avr/pgmspace.h.
CrossPack AVR
"CrossPack AVR" packages the toolchain for easy installation on Mac OS X:
Installs into /usr/local/CrossPack-AVR-20090415.
$ cd /usr/local
$ sudo ln -s CrossPack-AVR-20090415 CrossPack-AVR
Add to .bash_profile:
# CrossPack-AVR
if [ -e "/usr/local/CrossPack-AVR" ]; then
PATH="$PATH:/usr/local/CrossPack-AVR/bin"
export PATH
MANPATH="$MANPATH:/usr/local/CrossPack-AVR/man"
export MANPATH
fi
ATxmega
- The ATxmega series (at opposed to ATmega) is the new hotness, but they don't come in DIP packages, and they don't run on 5V.
- On 12-Jul-2009, I got an ATxmega128A1 to blink an LED. It comes in a TQFP100 package, so I used a $1.50 adapter board from FuturLec to bring the pins out to .1" headers.
- 3.6 volts max! My brain works in 5V, so I know someday I'm going to accidentally fry one of these chips.
- There are 10 ground pins and 10 power pins. They follow a nice pattern, except for pins 83 and 84.
- The ATxmega chips program using PDI (rather than SPI). The AVRISPmkII can handle PDI, but you may need to use AVR Studio to upgrade its firmware once (I had to borrow time on a Windows machine to do that).
Exploring the Instruction Set
- Earlier experiment: After reading the instruction-set documentation, I drew a couple of grids to get a better idea how the 65,536 opcodes were arranged. After doing that, the sequential listing produced from the following commands made a lot of sense.
jot -w ".word " 65536 0 | avr-as
avr-objdump -S a.out
Reference
avr-gcc tips
- It is possible to make a macro that allows compile-time "binary constants" even without a compiler-supported "0b00101010" syntax. I first saw this technique in the MiniPOV3 source.
- Use -Os to optimize for size. This is a lot like -O2.
- Use "inline" on some functions, as in "inline void foo() { ... }". Let the compiler do its job -- there is no need to "inline by pasting," cluttering up the source code.
- Use -std=gnu99 to get access to C99 features, such as "bool" (#include <stdbool.h>) and the ability to declare a variable anywhere you want, not just at the beginning of a scope.
Interesting Sensors
Assorted