Microcontroller Programming

Content Page Seed

Since I'm the guru for microcontroller programming, I took notes in lecture: 10.06 lecture notes

Here is a byproduct of my process of learning assembler assembler.txt

Here are the documents that I reference in assembler.txt

assembler.pdf
avr_instruction_set.pdf
tiny44_short.pdf
tiny44_long.pdf

My Interactive Program

The concept behind my interactive program was to use the microcontroller to turn single keystrokes into multiple character sequences. For example, it has always struck me that single keystrokes for common character combinations (e.g. "tion," "the," "ing") could potentially increase typing speed. For ease of use, we use all lower case, and bind character combinations to shifted single-letter keystrokes.

Step 1: Echo Echo

To confirm that I had understood at least some fraction of what I read about assembler, I loaded up the Tiny 44 with a version of hello.echo with a simple modification to make it print each received character twice instead of once. This meant adding an extra copy of the lines

mov txbyte, rxbyte
rcall putchar
rcall blink

Echo Echo (Assembler Code)

Step 2: Key Bindings

In order to associate a single keystroke with a sequence of characters, the assembler code has to match a received character to an entry in a table, and accordingly output the appropriate sequence of characters. First I found this table of binary character codes - the official table of the 1967 ASCII standard (thank you wikipedia)

In the code here I have bound "T" to "th" and "I" to "ing". From the table above, it is apparent that the character code for "T" is the binary number 1010100, and that for "I" is 1001001. Here is the main loop in the Thing code.

loop:
rcall getchar
mov txbyte, rxbyte
icase:
cpi txbyte, 0b1001001
brne tcase
print msgi
msgi: .db "ing",0
ldi txbyte,10
rcall putchar
rjmp loop
tcase:
cpi txbyte, 0b1010100
brne onward
print msgt
msgt: .db "th",0
rjmp loop
onward:
rcall putchar
rcall blink
mov txbyte, rxbyte
rcall putchar
rcall blink
ldi txbyte,10
rcall putchar
rjmp loop