Arduino GPS

Just to get my hands dirty and wrap it up with the AVR’s, I created a GPS data logger – using an Arduino board, GPS receiver chip, 4×20 LCD, and a uALFAT microSD board.

A good document on NMEA commands and data formats used by GPS chips is here. Regarding the GPS unit, it was SiRF vs Trimble, and I went for SiRF, the SiRF III (the EM-406A by USGlobalSat). I picked it over the Trimble Lassen IQ and the Parallax.

Great learning exercise for getting down to the bare-metal. I decided to write it in raw C (UART driver, LCD driver, flash data logger,…), all from scratch, instead of Arduino’s Wiring language. This amounts to pretty much reading most of the 300 page data sheet for the MCU, giving you a thorough understanding of all aspects of the MCU – GPIO, clocks, counters, interrupts, UART, SPI, I2C,… all related considerations like registers, masks, timings, memory organization,…

Arduino LCD

My first step, in my foray into embedded systems: interfaced a 4×20 character LCD panel to the Arduino. Details on interfacing any Hitachi HD44780 based LCD panel can be found here.

Went for the default parallel LCD’s. They’re cheap, about $15 for a 20×4 panel on eBay (HD44780). The serial ones cost about 2-3 more. These LCD panels allow you to use 4 data lines (with some bit-banging) instead of 8. Get one that is STN and transflective (vs reflective and transmissive), known for better contrast and brighter.

Check out also LCDProc.

The Arduino

Just got it today :-). The Arduino is a great learning platform for anyone interested in the embedded world. The entire platform is open (hardware schematics, bootloader, lots of examples, etc.).

Comes with a programming language that abstracts out lot of the bit-level stuff… but for learning purposes I’d recommend just using straight C – i.e. to get right down to the bare metal. You’ll probably end up reading two-thirds of the 350 page ATmega168 specs. Atmel’s AVR docs are really well done, with assembly language and bit-level C-language code snippets. Ubuntu has a ready-made GNU C toolchain for the AVR which works quiet well. There is also an Eclipse plugin.

Also, check this site out: Atmel AVR Application Notes. Tons of stuff. You don’t really need to buy any embedded systems books. Also Atmel AVR 8-bit Instruction Set.

ATmega128

The Atmel ATmega128 AVR is a nice little full featured general purpose 8-bit MCU (i.e. not including MCUs which add on a host of other features like controllers for LCD, USB, Ethernet MAC, DSP, MMU, etc.).

For my own quick reference:

Feature ATmega128 ATmega168 ATmega8
Flash 128K 16K 8K
SRAM 4K 1K
512
EEPROM 4K 1K
512
UART 2 1
1
8-bit Timer 2 2
2
16-bit Timer 2 1
1
PWM (channels) 6+2 5
3
10-bit A/D (channels)
8 6
8
DebugWire/OCD Y

Analog Y

JTAG Y

SPI 1 1
1
TWI 1 1
1

Which RTOS?

After scouring through a number of MCU’s I’ve decided to go with the Atmel AVR, in particular the ATmega168.

But then, my recent adventure into the Slug’s hardware, got me thinking ARM. I settled for Atmel’s AT91SAM7 series of ARM MCU’s.

My next thought was how I can run Debian/ARM on it. But unfortunately that was quickly ruled out – as the largest of the 7S or 7X series has only 512K Flash and 128K SRAM. Note that the 7SE series has an external memory bus.

So what can I squeeze into 256K Flash and 64K RAM? My hunt came up with these (in terms of the number of microcontrollers each has been ported to):

  1. FreeRTOS (free)
  2. uC/OS-II (commercial)
  3. eCos (pdf book: Embedded Software Development with eCos)
  4. TNKernel (free)

And these bootloaders:

  1. u-Boot
  2. Redboot
  3. Apex

Where to get parts ?!

Where do you go for basic electronic parts in the USA!? like discrete components and small chips — in single quantities, i.e. without having to bulk order them?

Back in India (and I think in most South Asian countries) most major cities have streets/bazaars full of electronic component shops (not consumer electronics, but components, semiconductors,…). It’s a electronics hobbyists heaven to find a street full of shops like that. So frustrating not to find something like that here in the USA, and RadioShack just doesn’t do it for me. But here’s my bookmark of some online shops:

Choosing a Microcontroller

As I went about choosing what is the good microcontroller to get started on, here’s my shortlist:

8/16 bit:

32-bit: