NET3001 Teaching Board
MTS: microcontroller training system
notes on machine code
For the last few years I have been teaching a course in real time
programming. The 3 month course consists of
The students write code on an embedded microprocessor, the HC12 for the
last few years. The students work with a large development box which is
kept in the lab area.
- assembly language programming
- C programming
- cooperative multitasking
I wanted to create a course where the students could bring the
development system home, and work with their own PC. That meant:
To demonstrate the various aspects of the course, the board must have:
- open source tools
- a small portable development system
- lowest cost (including development tools)
- a variety of easy-to-understand peripherals, with user interaction
- interrupts and real-time-clock
I am settling on something like this
- a 3"x4" board, battery powered; preferably a coin cell
- a CPU with 32kB of flash, probably an MSP430
- a programming port, which allows download and in circuit debugging
- LCD display, 2 lines of 8 (or 16) alpha chars
- 12 button keyboard
- beeper or speaker
- DC motor
- stepper motor
- 3 (or more LED's)
- temperature sensor
- light sensor
- 2-way radio module
- UART/serial back to the host CPU
I'd like the CPU to be easy to teach, which precludes the AVR series;
it's Harvard architecture, and that doesn't fit well with my notes. I
suppose I could jig them around a bit........
The AT91SAM series of ARM chips has a really awkward way of controlling
the DDR (data direction register) on the I/O ports.
Overall, the MSP430 series seems to give a nice mixture of Von Neumann
architecture and extremely low power.
The CPU needs to allow easy download and single stepping, as well as
the ability to view registers and control I/O ports. All the candidate
CPU's provide this function, although some of them are quite costly.
I'm settling on the MSP430 series. It can be debugged by controlling
the JTAG pins, and I can add a slave CPU to the board to convert a
serial protocol to the JTAG twiddling required. There is already open
source software to drive the serial port and it's integrated with the
The slave CPU is a $4 part, which has a built-in UART to talk to the
host, and enough pins to drive the JTAG. Hopefully I will find enough
pins & code space to have this device also drive the LCD. If not,
at least there should be enough room in it to at least drive the LCD
power; it would be to distracting to the students if they have to learn
about driving a square wave out, just to light up the LCD.
Almost all the chips on the board run at 3V, which is perfect for a
coin cell, without regulator. In the dollar-store, you can get 2 CR2032
cells for $1.
In order to run the two motors, however, we need a lot more current, so
the board has a separate set of connectors on the back to allow a 2xAAA
cell battery pack to be used as an alternative, again without a
regulator. If the usage does not require the two motors, then the coin
cell supply will do.
The only module which requires 5V is the LCD display. So the slave CPU
drives it, and pumps up a voltage doubler circuit to power the LCD when
it is required.
The students in the course are also learning about network protocols in
their other courses. So this board has a 2.4GHz radio transceiver. This
unit is low cost, only chews about 10mA when it's running, and has a
full packet fifo and MAC features (preamble, header and CRC assembly).
The students can either use it at this level, or introduce a link-level
protocol. The packet payload can be up to about 25 bytes, or even more
if the CRC & address fields are reduced.
There are two motors on board. The DC motor is driven by two PWM pins,
which allows us to speed it up and slow it down, and even reverse it.
The stepper motor is a 4 pin unipolar drive, so the drive sequences are
Both should be fairly easy to teach.
When the motors are used, we will have to use the AAA batteries.
Provisional: CDN$50 for parts. Labor will probably be me-&-free.
Many of the parts are coming from surplus houses, and Digikey.
Some assignments which I am considering
- light up the LED's
- read the temperature
- scan the keyboard
- connect keystroke to an LED
- report keystrokes to LCD
- measure human reaction time from beep-to-keystroke,
beep-to-handclap, led-to-keystroke, led-to-handclap
- build a frequency meter to measure audio frequencies
- build an echo-locater (ultrasonic click on the beeper to
- spin the motor
- use light feedback to regulate the speed (negative feedback
- send data through the radio
- build a mesh network using the radios
- car wash
- traffic lights
- car radio
- vending machine
Machine code notes
Just for information, I took the assignments from the last two years
and compiled them on the various architectures. This table shows the bytes of code only; the bytes of data
didn't change much between architectures.
*I had a hard time merging in libc, so this number is without printf()
& sprintf(), which probably add a kB or so
(482 lines of source)
(826 lines of source)