Robocon 2007 Electronics Quickstart! Session 2 First Program - GPIO Prepared by KI Chi Keung [chikeung@ust.hk] WONG Long Sing (Sam) [sam@hellosam.net]
Today’s Timeline Driving the Debug LED Reading a button Schematic Reading Special Function Register ATMega128 Specification Reading Hexadecimal / Bitwise Operation Deterministic Speed Reading a button Debouncing State
Schematic Reading Identify the Component Identify the Wire / Net Label Identify the Hardware pin
Special Function Register Identify the hardware module to be used GPIO? Timer? UART? I2C? Identify the SFR involved
ATMega128 Specification Reading It’s silly to read all 3xx pages in a single pass. Don’t try to do that. Only refer to what you need. Usually SFR description is what you needed.
Hexadecimal / Bitwise Operation 0x21 0b00100001 0x43 0b01000011 0xCD 0b11001101 0xFE 0b11111110 _BV(0) 0b00000001 _BV(1) 0b00000010 _BV(7) 0b10000000
Deterministic Speed Each assembly instruction takes defined CPU cycles to run, no more, no less. Period of CPU cycles depends on your clock While the clock is fixed now, so each instruction take exactly deterministic speed. This is true if and only if your program solely occupies the CPU.