Week 8
Embedded Programming
Morse Code Translator
For the assignment this week I wanted to make a board that flashed an LED according to the Morse code equivalent of the keystroke input via serial. The board that I designed for this is a minor modification of the standard attiny44 board from class. The code itself is modified from the echo hello-world program from class, which monitors the serial line for keystrokes from the computer.

I used WinAVR to program the board via the FabISP. The FabISP connects to the board via a six-pin SPI connector (SCK, MOSI/MISO). The FabISP is powered by its own USB plug, while my own board is powered from USB as well via its FTDI connector. The FTDI connector is used for serial communication via the USB port, and requires specific drivers. Otherwise, Device Manager will show an unrecognized USB device when the FTDI cable is connected to the computer. With WinAVR installed, the Windows operating system recognizes recognize the "make" command in the Command Prompt window. It looks for a file called "makefile" (no extension) in the active directory. The makefile is simply a collection of low-level AVR command line instructions that can be executed with more understandable text commands. In my code, the makefile is simply the one with the MAKE extension. To make it the active makefile, simply change its name to "makefile."
The "make" command compiles the C file targed in makefile into a HEX file that can be downloaded into the microprocessor. The actual download command is "make program-usbtiny." However, there is one more operation that is needed before the board will work properly. The code on the board assumes a particular baud rate for serial communication, determined by the 20 MHz external resonator connected to the attiny44. In order for the chip to use this clock and not its own internal clock, its hardware fuses must be set. This is done via the command "make program-usbtiny-fuses." However, it is crucial that this command is only executed with precisely the right fuse settings. Otherwise, the chip will become unprogrammable, because it will be expecting a nonexistent clock signal to advance it to the next instruction. In this case, an error like "initialization failed, rc=-1" will show up. Trying to program new fuses will not help, because the chip does not have the right clock signal. Solutions include connecting the right clock signal (not usually feasible with PCB's) or de-soldering the chip and replacing it with a new one that has default fuses set.

Here is a video of the Morse code translator in operation once the board has been successfully programmed.