Saturday, July 9, 2011

UCLA Embedded Course Overview

UCLA extension offers a 12 week evening course (Engineering x457.55) on programming embedded processors. Students use a Texas Instruments ARM evaluation kit which includes the processor mounted on an evaluation board with a Windows IDE to program the ARM chip.



The board has a 32 bit ARM chip running at up to 50 MHz. It has 64KB of flash, 8 KB of SRAM, hardware timers, digital and analog I/O. The board draws its power from the USB interface which also serves to program, debug and support a separate RS-232 style interface.

The course starts with writing a hardware abstraction layer (HAL) in C to set up hardware timers and I/O for the button and potentiometer. Since there isn't an operating system, the programmer must configure the board according to his needs including setting the clock speed of the CPU itself. The C main() method is called from a small bit of assembler that sets up the stack, heap and interrupt vectors.

Bugs frequently manifest with a hardware interrupt and no stack trace. One learns how to use the JTAG debugger to not only perform standard software debugging but to also set and query arbitrary memory addresses. This includes setting up or querying hardware.

The course then covers common design patterns for handling multiple I/O events. The common pattern we used was to code up an event loop where the hardware interrupts were mapped into events. To send a debugging printf() required that we set up the hardware for baud rate, character size and parity; load the first character into the outgoing FIFO; service the transmission complete interrupt and load the next character.

The course was wrapped up by replacing our event loop with a small, real time operating system (RTOS). We retained the assembly initialization, our HAL setup and interrupt routines but now set up semaphores, queues and tasks (threads) to partition the work. The RTOS is started as the last line of main() as opposed to having an operating system load the application.

This was an excellent introduction to the very different world of embedded systems. If you've wanted to play with hardware or embedded software, this is a great way to start.