20081006fabl.txt ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ microcontroller programming harvard: separate memory for program and data von Neumann: programs and memory in the same place microcontrollers are harvard architecture data and program memory operations run at the same time risc = reduced instruction set cisc = complex instruction set risc small set executed in each cycle compiler cisc ... risc is more prominent now x86 is cisc microproc vs microcont microproc is naked, needs interfaces to memory etc microcontroller has this inside portable => we use microcontrollers memory types sram = static ram, dynamic, quickly accessible - registers - small set of memory for instructions, processor reads from, writes to, operands to stuff - sram (density low) eeprom - electronically erasable - persistent denser storage, maintained longer more complex to program does many read/write cycles flash charge on floating gate gives nonvolatile storage programs stored for non-volatile better for dense, rewritten few times [eeprom vs flash: parameter space, number of rewrites, retention time,] fuse bits peripherals on microcontroller [tiny45 costs 45 cents] a/d = voltage to 10bits d/a = bits to voltage pulse with modulate bits (vary width of pulse) comparator - faster than a/d,d/a UART - bigger processors have it ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8051 processors: cisc, not risc messy to program but cheap can go fast old architecture dozens of companies manufacture TI: MSP430 low power categories: size of word (=8, eg) MSP is 16-bit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ we use AVR's 1 instruction per cycle pics = 4 instructions per cycle flat address space (??) high performance peripherals insanely cheap conceived by norwegian graduate students eye towards modern compilers gcc ... links in ... or something tool chain ... is why we're using them avr's good for bit-banging ntsc, pal ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment: skim attiny45 manual doc2586.pdf language reveals underlying processes there is an onboard rc clock up to 20 Mhz = 50 ns cycle knows how to sleep and wake up pulse width modulator everything it does is "memory mapped" ATtiny45 has exist c.2 years, family c.5 years dsp multiply accumulate for a filter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ neil likes machined prototypes because they self-document iterations, and you always know what they are. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mlf for really tiny stuff missed ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AVR.pdf p 17 describes "add" operation ATtiny45.pdf p 200 instruction set summary "op codes" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ timing rc, ceramic, quartz ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ processor, package, clock now program ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assembly language ".asm" write op codes, giving names to things one line = one instruction note: assembly language, high level language have separate history traditionally: assembly language codes not indented 3 ways to write progs: 1. assembly 2. gcc 3. interpreters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dive in to hello world program! "hello.serial.45.asm" assembler.pdf (atmel directives live on) .include does hardware mapping ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ldi- load immediate tmp - temporary registers ramend hi - give me the high byte set stack at top of ram (compilers do this) [note: compose by modifying, not writing from scratch] 3 registers per pin out asserts in reads (hold high reads switch) (default is listening) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 200kbit is limit -12,12 (high/low) we use -5,5 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RS232 0,5 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ hello world stored in flash as rs232 by uart - universal _ receiver, transmitter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ gavrasm - command line avr studio - gui ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ hello.serial.45.c avr libc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ makefile tells gcc how to build our program can have some in assembler, some in c hex with c is 913 bytes hex with assembler is 237 command: make program build, loaded c program assembler, assemble make, makefile, c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spi circuit programming ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ line driver chip ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ next hello world is echo hello.echo.45.asm set whether pins are in or out do nothing for a while to keep the led on for non-infinitessimal time ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 115200 does faster communications, but requires external quartz crystal clock ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment: make programming cable implement an interactive application ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ansi terminal ... screen redrawing ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ next week: eagle, cad, paint for pcb design ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^