MAS 863
How To Make (almost) Anything

Microcontroller Programming

Harvard, von Neumann architectures

RISC, CISC

microprocessors, microcontrollers

memory: registers, SRAM, EEPROM, FLASH, fuse

peripherals: A/D, D/A, comparator, timer/counter/PWM, UART, ...

word size: 8, 16, 32, 64

8051, PIC, MSP, AVR, ARM

ATtiny45, ATtiny44, ATmega88/168, ATmega644

DIP, SOIC, TQFP, MLF

RC, ceramic, quartz

instruction sets, opcodes, hex files

assembly language
   mnemonics, directives, expressions
   AVR Studio
   avr-as
   gavrasm

C
   AVR Libc
   avr-libc, gcc-avr, binutils-avr
   WinAVR

interpreters
   Basic, Python, ...
   Arduino
   Scratch

in-circuit programming
   ICE, JTAG, Dragon
   avrdude
      tiny45 load hex file, bsd cable: avrdude -p t45 -c bsd -U flash:w:file.hex
      tiny45 load hex file, dasa cable: avrdude -p t45 -P /dev/ttyUSB0 -c dasa -U flash:w:file.hex
      tiny44 load hex file: avrdude -p t44 -c bsd -U flash:w:file.hex
      tiny44 use 20 MHz xtal: avrdude -p t44 -c bsd -U lfuse:w:0x7E:m
      mega88 load hex file: avrdude -p m88 -c bsd -U flash:w:file.hex
      mega88 use 20 MHz xtal: avrdude -p m88 -c bsd -U lfuse:w:0x76:m

MTA tool

cables
   ATtiny45 programming cable:
              7 - reset - 1 8 -
                        - 2 7 - SCK - 8
                        - 3 6 - MISO - 10
               18 - GND - 4 5 - MOSI - 9
   
                    4   1  7  5   6          clip
      1  2  3  4  5  6  7  8  9  10 11 12 13 DB25
       14 15 16 17 18 19 20 21 22 23 24 25   DB25
   
   in-circuit programming AMP MTA plug <-> DB25M parallel (bsd) cable (wire side view):
   
            9        18        10
      | MOSI (3)  GND (2)  MISO (1) |
         -RESET (4)  SCK (5)
               7        8
                     | cable direction
                     v
   
      plug               1   3   5   4     2
      DB25  13  12  11  10   9   8   7   6   5   4   3   2   1
      DB25    25  24  23  22  21  20  19  18  17  16  15  14
   
   in-circuit programming AMP MTA plug <-> DB9F serial (dasa) cable (wire side view):
   
                     ^
                     | cable direction
            3        5         8
      | MOSI (3)  GND (2)  MISO (1) |
         -RESET (4)  SCK (5)
               7        4
   
      plug         4 3 1 5   2        
            DCD  Rx  Tx DTR GND
              DSR RTS CTS  RI
      DB9    1   2   3   4   5
      DB9      6   7   8   9
   
      serial programming voltage limiter: dasa.cad
   
   serial AMP MTA plug <-> DB9F cable (wire side view):
   
         Tx GND
      |  2   1 |
       3   4
       Rx DTR
          | cable direction
          v
   
      plug      3   2   4   1
           DCD  Rx  Tx DTR GND
             DSR RTS CTS  RI
      DB9   1   2   3   4   5
      DB9     6   7   8   9

rx.py, term.py, Kermit

VT100/ANSI/ISO/ECMA terminal

serial output:
   hello.serial.45.cad
   hello.serial.45.asm
   hello.serial.45.hex
   hello.serial.45.c
   makefile
serial echo:
   hello.echo.45.cad
   hello.echo.45.asm
   hello.echo.45.c
   makefile
   hello.echo.44.cad
   hello.echo.44.asm

assignment:
   * make cables for in-circuit programming and serial communications
   * develop an interactive microcontroller application (a command interpreter, a shell, a game, ...)

lab sections
   Charlie: Tuesday 2:00-4:00
   Siggi: Wednesday 3:00-5:00
   Eric: Thursday 2:00-4:00

10/14: 3:00 023 (PCB design)