2.7.2 Power Consumption and Sleep ......................... 69
2.7.3 Reset ...................................... 70
2.7.4 Exercises .................................... 71
3 Communication Interfaces 73
3.1 SCI (UART) ....................................... 75
3.2 SPI ............................................ 82
3.3 IIC (I2C) ........................................ 83
3.3.1 Data Transmission ............................... 84
3.3.2 Speed Control Through Slave ......................... 87
3.3.3 Multi-Master Mode ............................... 87
3.3.4 Extended Addresses .............................. 88
3.4 Exercises ........................................ 88
4 Software Development 89
4.1 Development Cycle ................................... 91
4.1.1 Design Phase .................................. 91
4.1.2 Implementation ................................. 92
4.1.3 Testing & Debugging .............................. 94
4.2 Programming ...................................... 97
4.2.1 Assembly Language Programming ....................... 97
4.3 Download ........................................ 117
4.3.1 Programming Interfaces ............................ 117
4.3.2 Bootloader ................................... 118
4.3.3 File Formats .................................. 118
4.4 Debugging ........................................ 121
4.4.1 No Debugger .................................. 121
4.4.2 ROM Monitor ................................. 124
4.4.3 Instruction Set Simulator ............................ 124
4.4.4 In-Circuit Emulator ............................... 125
4.4.5 Debugging Interfaces .............................. 125
4.5 Exercises ........................................ 127
5 Hardware 129
5.1 Switch/Button ...................................... 129
5.2 Matrix Keypad ..................................... 130
5.3 Potentiometer ...................................... 132
5.4 Phototransistor ..................................... 132
5.5 Position Encoder .................................... 133
5.6 LED ........................................... 134
5.7 Numeric Display .................................... 135
5.8 Multiplexed Display .................................. 136
5.9 Switching Loads .................................... 138
5.10 Motors .......................................... 140
5.10.1 Basic Principles of Operation ......................... 140
5.10.2 DC Motor .................................... 142
5.10.3 Stepper Motor ................................. 146
5.11 Exercises ........................................ 153
ii