Preface |
|
xx | |
|
Chapter 1 Microcontrollers for Embedded Systems |
|
|
1 | (12) |
|
|
1 | (1) |
|
|
1 | (3) |
|
|
2 | (1) |
|
1.2.2 Programming the PIC |
|
|
2 | (1) |
|
|
3 | (1) |
|
|
4 | (1) |
|
|
4 | (9) |
|
1.3.1 Baseline PIC Family |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
7 | (2) |
|
|
9 | (1) |
|
|
9 | (1) |
|
|
9 | (1) |
|
1.3.3 High-Performance PIC s and DSPs |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
12 | (1) |
|
Chapter 2 PIC 18 Architecture |
|
|
13 | (24) |
|
2.1 PIC 18 Family Overview |
|
|
13 | (9) |
|
|
14 | (1) |
|
2.1.2 PIC 18FXX2 Device Group Overview |
|
|
15 | (1) |
|
2.1.3 PIC 18F4X2 Block Diagram |
|
|
16 | (1) |
|
2.1.4 Central Processing Unit |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (1) |
|
2.1.5 Special CPU Features |
|
|
19 | (1) |
|
|
20 | (1) |
|
|
21 | (1) |
|
|
21 | (1) |
|
|
21 | (1) |
|
|
22 | (7) |
|
|
22 | (1) |
|
|
23 | (1) |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
25 | (2) |
|
|
27 | (1) |
|
2.2.5 Indirect Addressing |
|
|
28 | (1) |
|
2.3 PIC 18FXX2 Oscillator |
|
|
29 | (2) |
|
|
29 | (1) |
|
Crystal Oscillator and Ceramic Resonator |
|
|
29 | (1) |
|
|
30 | (1) |
|
|
31 | (1) |
|
Phase Locked Loop Oscillator Mode |
|
|
31 | (1) |
|
|
31 | (3) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
33 | (1) |
|
Oscillator Start-Up Timer (OST) |
|
|
33 | (1) |
|
|
33 | (1) |
|
|
33 | (1) |
|
|
33 | (1) |
|
|
34 | (1) |
|
|
34 | (1) |
|
2.5.2 Parallel Slave Port |
|
|
35 | (1) |
|
|
35 | (2) |
|
|
35 | (2) |
|
Chapter 3 Programming Tools and Software |
|
|
37 | (34) |
|
|
37 | (3) |
|
|
37 | (1) |
|
3.1.2 High-and Low-Level Languages |
|
|
38 | (2) |
|
3.1.3 Language-Specific Software |
|
|
40 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
3.3 An Integrated Development Environment |
|
|
41 | (9) |
|
|
42 | (1) |
|
3.3.2 Creating the Project |
|
|
43 | (2) |
|
3.3.3 Setting the Project Build Options |
|
|
45 | (2) |
|
3.3.4 Adding a Source File |
|
|
47 | (1) |
|
3.3.5 Building the Project |
|
|
48 | (1) |
|
|
48 | (2) |
|
|
50 | (1) |
|
3.4 MPLAB Simulators and Debuggers |
|
|
50 | (6) |
|
|
51 | (1) |
|
|
51 | (1) |
|
|
52 | (1) |
|
|
52 | (2) |
|
|
54 | (1) |
|
|
54 | (1) |
|
3.4.3 MPLAB Hardware Debuggers |
|
|
55 | (1) |
|
3.4.4 An Improvised Debugger |
|
|
56 | (1) |
|
3.5 Development Programmers |
|
|
56 | (5) |
|
3.5.1 Microchip PIC kit 2 and PIC kit 3 |
|
|
58 | (2) |
|
3.5.2 Micropro USB PIC Programmer |
|
|
60 | (1) |
|
3.5.3 MPLAB ICD 2 and ICD 3 In-Circuit Debuggers/Programmers |
|
|
60 | (1) |
|
3.6 Test Circuits and Development Boards |
|
|
61 | (10) |
|
3.6.1 Commercial Development Boards |
|
|
61 | (2) |
|
|
63 | (1) |
|
|
64 | (1) |
|
Limitations of Breadboards |
|
|
65 | (1) |
|
Breadboarding Tools and Techniques |
|
|
66 | (1) |
|
|
67 | (1) |
|
|
67 | (1) |
|
3.6.6 Printed Circuit Boards |
|
|
68 | (3) |
|
Chapter 4 Assembly Language Program |
|
|
71 | (14) |
|
4.1 Assembly Language Code |
|
|
71 | (4) |
|
|
71 | (2) |
|
|
73 | (1) |
|
Program Environment Directives |
|
|
73 | (1) |
|
|
73 | (1) |
|
Error Message Level Control |
|
|
74 | (1) |
|
|
74 | (1) |
|
|
74 | (1) |
|
|
74 | (1) |
|
|
75 | (1) |
|
4.2 Defining Data Elements |
|
|
75 | (2) |
|
|
76 | (1) |
|
|
76 | (1) |
|
4.2.3 Access to Banked Memory |
|
|
77 | (1) |
|
|
77 | (2) |
|
4.3.1 Register and Bit Names |
|
|
77 | (2) |
|
4.4 PIC 18FXX2 Instruction Set |
|
|
79 | (6) |
|
4.4.1 Byte-Oriented Instructions |
|
|
80 | (1) |
|
4.4.2 Bit-Oriented Instructions |
|
|
80 | (1) |
|
4.4.3 Literal Instructions |
|
|
80 | (1) |
|
4.4.4 Control Instructions |
|
|
80 | (5) |
|
Chapter 5 PIC 18 Programming in C Language |
|
|
85 | (18) |
|
|
85 | (1) |
|
5.1.1 C versus Assembly Language |
|
|
85 | (1) |
|
|
86 | (1) |
|
5.2 MPLAB C18 Installation |
|
|
86 | (5) |
|
5.2.1 MPLAB Software Components |
|
|
87 | (1) |
|
5.2.2 Configuration Options |
|
|
88 | (1) |
|
5.2.3 System Requirements |
|
|
89 | (1) |
|
|
90 | (1) |
|
|
91 | (7) |
|
5.3.1 Creating the Project |
|
|
91 | (1) |
|
|
92 | (1) |
|
Select the Language Toolsuite |
|
|
92 | (1) |
|
|
93 | (2) |
|
|
95 | (1) |
|
5.3.2 Selecting the Build Directory |
|
|
96 | (2) |
|
|
98 | (5) |
|
5.4.1 Source Code Analysis |
|
|
99 | (1) |
|
|
100 | (1) |
|
|
101 | (2) |
|
Chapter 6 C Language in an Embedded Environment |
|
|
103 | (22) |
|
|
103 | (1) |
|
6.1.1 PIC 18 Extended Mode |
|
|
104 | (1) |
|
|
104 | (2) |
|
|
104 | (1) |
|
6.2.2 Online Help for C18 and Libraries |
|
|
105 | (1) |
|
6.3 Processor-Independent Libraries |
|
|
106 | (9) |
|
6.3.1 General Software Library |
|
|
106 | (1) |
|
Character Classification Functions |
|
|
107 | (1) |
|
Data Conversion Functions |
|
|
107 | (1) |
|
Memory and String Manipulation Functions |
|
|
108 | (2) |
|
|
110 | (1) |
|
|
111 | (1) |
|
Character Output Functions |
|
|
112 | (3) |
|
6.4 Processor-Specific Libraries |
|
|
115 | (3) |
|
6.4.1 Hardware Peripheral Library Functions |
|
|
115 | (1) |
|
6.4.2 Software Peripherals Library Functions |
|
|
116 | (1) |
|
6.4.3 Macros for Inline Assembly |
|
|
116 | (1) |
|
6.4.4 Processor-Specific Header Files |
|
|
117 | (1) |
|
|
118 | (4) |
|
6.5.1 ANSI-IEEE 754 Binary Floating-Point Standard |
|
|
118 | (1) |
|
|
119 | (1) |
|
|
119 | (1) |
|
6.5.2 Standard Math Library Functions |
|
|
120 | (1) |
|
6.5.3 Floating-Point Math Sample Program |
|
|
120 | (2) |
|
6.6 C18 Language Specifics |
|
|
122 | (3) |
|
6.6.1 C18 Integer Data Types |
|
|
122 | (1) |
|
6.6.2 C18 Floating-Point Data Types |
|
|
122 | (1) |
|
|
123 | (1) |
|
|
123 | (1) |
|
6.6.5 Static Function Argument |
|
|
123 | (1) |
|
|
123 | (1) |
|
|
123 | (1) |
|
|
124 | (1) |
|
Chapter 7 Programming Simple Input and Output |
|
|
125 | (22) |
|
|
125 | (6) |
|
7.1.1 A Simple Circuit and Code |
|
|
125 | (1) |
|
|
125 | (1) |
|
7.1.3 Assembler Simple I/O Program |
|
|
126 | (3) |
|
7.1.4 Assembler Source Code Analysis |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
7.2 C Language Simple I/O Program |
|
|
131 | (3) |
|
7.2.1 C Source Code Analysis |
|
|
132 | (1) |
|
|
133 | (1) |
|
7.3 Seven-Segment LED Programming |
|
|
134 | (7) |
|
|
135 | (1) |
|
7.3.2 Assembler Seven-Segment LED Program |
|
|
136 | (1) |
|
|
136 | (1) |
|
Port A for Digital Operation |
|
|
137 | (1) |
|
|
138 | (1) |
|
Seven-Segment Code with Computed Goto |
|
|
139 | (1) |
|
7.3.3 Assembler Table Lookup Sample Program |
|
|
140 | (1) |
|
7.4 C Language Seven-Segment LED Programs |
|
|
141 | (2) |
|
7.4.1 Code Selection by Switch Construct |
|
|
142 | (1) |
|
7.4.2 Code Selection by Table Lookup |
|
|
142 | (1) |
|
7.5 A Demonstration Board |
|
|
143 | (4) |
|
|
145 | (1) |
|
|
145 | (2) |
|
|
147 | (32) |
|
|
147 | (1) |
|
8.2 PIC 18 Interrupt System |
|
|
147 | (10) |
|
|
148 | (1) |
|
8.2.2 Interrupt Control and Status Registers |
|
|
148 | (1) |
|
|
149 | (2) |
|
|
151 | (1) |
|
|
152 | (1) |
|
|
152 | (2) |
|
8.2.3 Interrupt Priorities |
|
|
154 | (1) |
|
|
154 | (1) |
|
|
155 | (1) |
|
An Interrupt Interrupting Another One |
|
|
155 | (1) |
|
8.2.4 Context Saving Operations |
|
|
155 | (1) |
|
Context Saving during Low-Priority Interrupts |
|
|
156 | (1) |
|
|
157 | (11) |
|
8.3.1 Port B External Interrupt |
|
|
158 | (1) |
|
8.3.2 INT0 Interrupt Demo Program |
|
|
158 | (1) |
|
|
158 | (1) |
|
|
159 | (1) |
|
|
160 | (1) |
|
|
160 | (1) |
|
|
161 | (1) |
|
Interrupt Service Routine |
|
|
161 | (1) |
|
|
162 | (1) |
|
|
162 | (1) |
|
8.3.3 Port B Line Change Interrupt |
|
|
163 | (1) |
|
|
164 | (1) |
|
Multiple External Interrupts |
|
|
165 | (1) |
|
8.3.4 Port B Line Change Interrupt Demo Program |
|
|
165 | (1) |
|
Setting Up the Line Change Interrupt |
|
|
165 | (1) |
|
Interrupt Service Routine |
|
|
166 | (2) |
|
8.4 Sleep Mode and Interrupts |
|
|
168 | (3) |
|
|
169 | (1) |
|
|
170 | (1) |
|
8.5 Interrupt Programming in C Language |
|
|
171 | (8) |
|
|
171 | (1) |
|
|
172 | (1) |
|
|
172 | (1) |
|
8.5.2 Interrupt Programming in C18 |
|
|
173 | (1) |
|
Sleep Mode and RBO Interrupt Demo Program |
|
|
174 | (2) |
|
Port B Interrupt on Change Demo Program |
|
|
176 | (3) |
|
Chapter 9 Delays, Counters, and Timers |
|
|
179 | (48) |
|
|
179 | (1) |
|
|
179 | (3) |
|
9.2.1 Power-Up Timer (PWRT) |
|
|
179 | (1) |
|
9.2.2 Oscillator Start-Up Timer (OST) |
|
|
180 | (1) |
|
9.2.3 Phase Locked Loop (PLL) |
|
|
180 | (1) |
|
|
181 | (1) |
|
|
181 | (1) |
|
|
181 | (1) |
|
9.3 Hardware Timer-Counters |
|
|
182 | (1) |
|
|
182 | (17) |
|
9.4.1 Timer0 Architecture |
|
|
184 | (1) |
|
|
184 | (1) |
|
|
185 | (1) |
|
|
185 | (1) |
|
|
185 | (1) |
|
|
186 | (1) |
|
9.4.2 Timer0 as a Delay Timer |
|
|
186 | (1) |
|
|
187 | (1) |
|
|
188 | (1) |
|
|
188 | (1) |
|
Delays with 16-Bit Timer0 |
|
|
189 | (1) |
|
9.4.3 Counter and Timer Programming |
|
|
189 | (1) |
|
|
190 | (1) |
|
Timer0_as_Counter.asm Program |
|
|
190 | (1) |
|
A Timer/Counter Test Circuit |
|
|
191 | (1) |
|
Timer0 _Delay.asm Program |
|
|
191 | (2) |
|
A Variable Time-Lapse Routine |
|
|
193 | (1) |
|
Timer0_VarDelay.asm Program |
|
|
193 | (3) |
|
|
196 | (3) |
|
|
199 | (11) |
|
|
199 | (1) |
|
|
200 | (1) |
|
Timer1 in Synchronized Counter Mode |
|
|
201 | (1) |
|
External Clock Input Timing in Synchronized Mode |
|
|
201 | (1) |
|
Timer1 Read and Write Operations |
|
|
201 | (1) |
|
|
201 | (1) |
|
|
202 | (1) |
|
Reading and Writing Timer1 in Two 8-bit Operations |
|
|
202 | (1) |
|
|
203 | (1) |
|
|
204 | (1) |
|
|
204 | (1) |
|
|
205 | (1) |
|
|
205 | (1) |
|
|
205 | (2) |
|
|
207 | (1) |
|
Timer3 in Synchronized Counter Mode |
|
|
207 | (1) |
|
External Clock Input Timing |
|
|
208 | (1) |
|
Timer3 in Asynchronous Counter Mode |
|
|
208 | (1) |
|
External Clock Input Timing with Unsynchronized Clock |
|
|
208 | (1) |
|
Timer3 Reading and Writing |
|
|
208 | (1) |
|
|
208 | (1) |
|
16-bit Read-Modify-Write Operation |
|
|
209 | (1) |
|
Reading in Asynchronous Counter Mode |
|
|
209 | (1) |
|
Timer1 Oscillator in Timer3 |
|
|
210 | (1) |
|
|
210 | (2) |
|
9.6.1 CloseTimerx Function |
|
|
210 | (1) |
|
9.6.2 OpenTimerx Function |
|
|
211 | (1) |
|
9.6.3 ReadTimerx Function |
|
|
211 | (1) |
|
9.6.4 WriteTimerx Function |
|
|
212 | (1) |
|
|
212 | (15) |
|
9.7.1 Timer0_as_Counter program |
|
|
212 | (3) |
|
9.7.2 Timer0_Delay Program |
|
|
215 | (1) |
|
9.7.3 Timer0_VarDelay Program |
|
|
216 | (4) |
|
9.7.4 Timer0_VarInt Program |
|
|
220 | (4) |
|
9.7.5 C_Timer_Show Program |
|
|
224 | (3) |
|
|
227 | (12) |
|
10.1 EEPROM on the PIC 18 Microcontrollers |
|
|
227 | (1) |
|
10.1.2 On-Board Data EEPROM |
|
|
227 | (1) |
|
|
228 | (3) |
|
10.2.1 Reading EEPROM Data |
|
|
228 | (2) |
|
10.2.2 Writing EEPROM Data |
|
|
230 | (1) |
|
10.3 Data EEPROM Programming in C Language |
|
|
231 | (2) |
|
10.3.1 EEPROM Library Functions |
|
|
232 | (1) |
|
|
232 | (1) |
|
10.4 EEPROM Demonstration Programs |
|
|
233 | (6) |
|
10.4.1 EEPROM_to_7Seg Program |
|
|
233 | (4) |
|
10.4.2 C_EEPROM_Demo Program |
|
|
237 | (2) |
|
Chapter 11 Liquid Crystal Displays |
|
|
239 | (64) |
|
|
239 | (4) |
|
11.1.1 LCD Features and Architecture |
|
|
239 | (1) |
|
11.1.2 LCD Functions and Components |
|
|
240 | (1) |
|
|
240 | (1) |
|
|
240 | (1) |
|
|
240 | (1) |
|
|
240 | (1) |
|
Character Generator ROM (CGROM) |
|
|
241 | (1) |
|
Character Generator RAM (CGRAM) |
|
|
241 | (1) |
|
Timing Generation Circuit |
|
|
241 | (1) |
|
Liquid Crystal Display Driver Circuit |
|
|
242 | (1) |
|
Cursor/Blink Control Circuit |
|
|
242 | (1) |
|
11.1.3 Connectivity and Pin Out |
|
|
242 | (1) |
|
11.2 Interfacing with the HD44780 |
|
|
243 | (4) |
|
11.2.1 Busy Flag and Timed Delay Options |
|
|
244 | (1) |
|
|
245 | (1) |
|
|
245 | (1) |
|
11.2.4 Display Memory Mapping |
|
|
245 | (2) |
|
11.3 The HD44780 Instruction Set |
|
|
247 | (4) |
|
11.3.1 Instruction Set Overview |
|
|
247 | (1) |
|
|
248 | (1) |
|
|
248 | (1) |
|
|
248 | (1) |
|
Display and Cursor ON/OFF |
|
|
248 | (1) |
|
|
248 | (1) |
|
|
248 | (1) |
|
|
249 | (1) |
|
|
249 | (1) |
|
Read Busy Flag and Address Register |
|
|
249 | (1) |
|
|
249 | (1) |
|
|
250 | (1) |
|
11.3.2 18F452 8-Bit Data Mode Circuit |
|
|
250 | (1) |
|
|
251 | (27) |
|
11.4.1 Defining Constants and Variables |
|
|
252 | (1) |
|
|
252 | (1) |
|
11.4.2 Using MPLAB Data Directives |
|
|
253 | (1) |
|
Data Definition in Absolute Mode |
|
|
253 | (1) |
|
|
254 | (1) |
|
Issues with Initialized Data |
|
|
254 | (1) |
|
11.4.3 LCD Initialization |
|
|
255 | (1) |
|
|
255 | (1) |
|
|
256 | (1) |
|
|
256 | (1) |
|
|
256 | (1) |
|
|
257 | (1) |
|
|
257 | (1) |
|
|
258 | (1) |
|
|
258 | (1) |
|
|
258 | (1) |
|
11.4.4 Auxiliary Operations |
|
|
259 | (1) |
|
|
259 | (1) |
|
|
260 | (1) |
|
|
261 | (1) |
|
|
262 | (2) |
|
11.4.5 Text Data Storage and Display |
|
|
264 | (1) |
|
Generating and Storing a Text String |
|
|
265 | (1) |
|
|
265 | (1) |
|
Displaying the Text String |
|
|
266 | (2) |
|
Sample Program LCD_18F_MsgFlag |
|
|
268 | (10) |
|
11.5 Data Compression Techniques |
|
|
278 | (13) |
|
11.5.1 4-Bit Data Transfer Mode |
|
|
279 | (1) |
|
11.5.2 Preserving Port Data |
|
|
279 | (1) |
|
11.5.3 Master/Slave Systems |
|
|
280 | (1) |
|
11.5.4 4-Bit LCD Interface Sample Programs |
|
|
281 | (10) |
|
11.6 LCD Programming in C18 |
|
|
291 | (8) |
|
|
292 | (1) |
|
|
292 | (1) |
|
Defining the Data Port and Tris Register |
|
|
293 | (1) |
|
|
294 | (1) |
|
11.6.3 XLCD Library Functions |
|
|
295 | (1) |
|
|
295 | (1) |
|
|
296 | (1) |
|
|
296 | (1) |
|
|
296 | (1) |
|
|
296 | (1) |
|
|
297 | (1) |
|
|
297 | (1) |
|
|
297 | (1) |
|
|
298 | (1) |
|
|
298 | (1) |
|
11.7 LCD Application Development in C18 |
|
|
299 | (4) |
|
11.7.1 Using the Project Wizard |
|
|
299 | (1) |
|
|
300 | (3) |
|
Chapter 12 Real-Time Clocks |
|
|
303 | (40) |
|
|
303 | (6) |
|
12.1.1 Clock Signal Source |
|
|
303 | (1) |
|
|
304 | (1) |
|
12.1.2 Programming the Timer1 Clock |
|
|
305 | (1) |
|
Setting Up Timer1 Hardware |
|
|
305 | (1) |
|
Coding the Interrupt Handler |
|
|
306 | (1) |
|
Sample Program RTC_18F_Timer1.asm |
|
|
306 | (3) |
|
|
309 | (9) |
|
|
310 | (1) |
|
12.2.2 6355 Data Formatting |
|
|
310 | (1) |
|
12.2.3 Initialization and Clock Primitives |
|
|
311 | (1) |
|
Reading and Writing Clock Data |
|
|
311 | (3) |
|
|
314 | (2) |
|
|
316 | (2) |
|
12.3 RTC Demonstration Circuit and Program |
|
|
318 | (18) |
|
12.3.1 RTC_F18_6355.asm Program |
|
|
318 | (1) |
|
|
319 | (1) |
|
|
319 | (17) |
|
12.4 Real-Time Clocks in C18 |
|
|
336 | (7) |
|
12.4.1 Timer1-Based RTC in C18 |
|
|
336 | (7) |
|
Chapter 13 Analog Data and Devices |
|
|
343 | (34) |
|
13.1 Operations on Computer Data |
|
|
343 | (1) |
|
|
343 | (22) |
|
13.2.1 A/D Module on the 18F452 |
|
|
344 | (1) |
|
|
345 | (2) |
|
|
347 | (1) |
|
|
348 | (1) |
|
13.2.2 A/D Module Sample Circuit and Program |
|
|
349 | (1) |
|
|
350 | (1) |
|
|
351 | (1) |
|
13.2.3 A2D_Pot2LCD Program |
|
|
352 | (13) |
|
13.3 A/D Conversion in C18 |
|
|
365 | (6) |
|
13.3.1 Conversion Primitives |
|
|
365 | (1) |
|
|
365 | (1) |
|
|
365 | (1) |
|
|
366 | (1) |
|
|
366 | (1) |
|
|
367 | (1) |
|
|
367 | (1) |
|
13.3.2 C_ADConvert.c Program |
|
|
368 | (1) |
|
C_ADConvert.c Code Listing |
|
|
368 | (3) |
|
13.4 Interfacing with Analog Devices |
|
|
371 | (6) |
|
13.4.1 LM 34 Temperature Sensor |
|
|
371 | (1) |
|
|
372 | (1) |
|
|
372 | (1) |
|
13.4.3 C_ADC_LM35.c Program |
|
|
373 | (4) |
|
Chapter 14 Operating Systems |
|
|
377 | (36) |
|
14.1 Time-Critical Systems |
|
|
377 | (1) |
|
14.1.2 Multitasking in Real-Time |
|
|
378 | (1) |
|
|
378 | (3) |
|
14.2.1 Tasks, Priorities, and Deadlines |
|
|
379 | (2) |
|
14.2.2 Executing in Real-Time |
|
|
381 | (1) |
|
|
381 | (3) |
|
14.3.1 Foreground and Background Tasks |
|
|
382 | (1) |
|
|
382 | (1) |
|
|
383 | (1) |
|
14.3.3 Clock-Tick Interrupt |
|
|
383 | (1) |
|
14.3.4 Interrupts in Preemptive Multitasking |
|
|
383 | (1) |
|
14.4 Constructing the Scheduler |
|
|
384 | (2) |
|
|
384 | (1) |
|
14.4.2 Round-Robin Scheduling |
|
|
385 | (1) |
|
14.4.3 Task States and Prioritized Scheduling |
|
|
385 | (1) |
|
14.5 A Small System Example |
|
|
386 | (2) |
|
|
386 | (1) |
|
|
387 | (1) |
|
14.6 Sample OS Application |
|
|
388 | (25) |
|
Appendix A MPLAB C18 Language Tutorial |
|
|
413 | (78) |
|
|
413 | (6) |
|
|
413 | (1) |
|
A.1.2 Communicating with an Alien Intelligence |
|
|
414 | (1) |
|
|
415 | (2) |
|
|
417 | (1) |
|
|
418 | (1) |
|
|
418 | (1) |
|
|
419 | (1) |
|
A.2 Structure of a C Program |
|
|
419 | (9) |
|
A.2.1 Sample Program C_LEDs_ON |
|
|
420 | (1) |
|
|
420 | (1) |
|
|
421 | (1) |
|
|
421 | (1) |
|
A.2.2 Sample Program C_LEDs_Flash |
|
|
422 | (1) |
|
Expressions and Statements |
|
|
423 | (1) |
|
|
423 | (2) |
|
Scope and Lifetime of a Variable |
|
|
425 | (1) |
|
|
426 | (1) |
|
|
427 | (1) |
|
|
428 | (1) |
|
|
428 | (3) |
|
|
429 | (1) |
|
|
430 | (1) |
|
A.3.3 Arrays of Alphanumeric Data |
|
|
430 | (1) |
|
A.3.4 Arrays of Numeric Data |
|
|
431 | (1) |
|
|
431 | (5) |
|
A.4.1 Storage of C Language Variables |
|
|
432 | (1) |
|
A.4.2 Address of Operator |
|
|
432 | (1) |
|
A.4.3 Indirection Operator |
|
|
433 | (1) |
|
A.4.4 Pointers to Array Variables |
|
|
434 | (1) |
|
|
435 | (1) |
|
|
436 | (15) |
|
|
436 | (1) |
|
A.5.2 Assignment Operator |
|
|
437 | (1) |
|
A.5.3 Arithmetic Operators |
|
|
438 | (1) |
|
|
439 | (1) |
|
|
439 | (1) |
|
A.5.5 Increment and Decrement |
|
|
440 | (1) |
|
A.5.6 Relational Operators |
|
|
441 | (1) |
|
|
442 | (1) |
|
|
443 | (2) |
|
|
445 | (1) |
|
|
446 | (1) |
|
|
447 | (1) |
|
|
447 | (1) |
|
Shift-Left and Shift-Right Operators |
|
|
448 | (1) |
|
A.5.9 Compound Assignment Operators |
|
|
449 | (1) |
|
A.5.10 Operator Hierarchy |
|
|
449 | (1) |
|
|
450 | (1) |
|
A.6 Directing Program Flow |
|
|
451 | (9) |
|
A.6.1 Decisions Constructs |
|
|
451 | (1) |
|
|
451 | (1) |
|
|
452 | (1) |
|
|
452 | (2) |
|
|
454 | (1) |
|
|
454 | (2) |
|
|
456 | (1) |
|
|
457 | (3) |
|
|
460 | (1) |
|
A.7 Loops and Program Flow Control |
|
|
460 | (6) |
|
A.7.1 Loops and Iterations |
|
|
461 | (1) |
|
A.7.2 Elements of a Program Loop |
|
|
461 | (1) |
|
|
462 | (2) |
|
Compound Statement in Loops |
|
|
464 | (1) |
|
|
464 | (1) |
|
|
465 | (1) |
|
|
466 | (3) |
|
|
466 | (1) |
|
|
467 | (1) |
|
|
468 | (1) |
|
A.9 Functions and Structured Programming |
|
|
469 | (5) |
|
A.9.1 Modular Construction |
|
|
469 | (1) |
|
A.9.2 Structure of a Function |
|
|
470 | (1) |
|
|
470 | (1) |
|
|
471 | (1) |
|
|
471 | (1) |
|
|
472 | (1) |
|
Matching Arguments and Parameters |
|
|
473 | (1) |
|
A.10 Visibility of Function Arguments |
|
|
474 | (4) |
|
A.10.1 Using External Variables |
|
|
474 | (1) |
|
A.10.2 Passing Data by Reference |
|
|
475 | (1) |
|
|
475 | (1) |
|
|
476 | (1) |
|
A.10.3 Function-Like Macros |
|
|
477 | (1) |
|
|
477 | (1) |
|
A.11 Structures, Bit Fields, and Unions |
|
|
478 | (13) |
|
A.11.1 Structure Declaration |
|
|
478 | (1) |
|
Structure Type Declaration |
|
|
479 | (1) |
|
Structure Variable Declaration |
|
|
479 | (1) |
|
A.11.2 Accessing Structure Elements |
|
|
480 | (1) |
|
Initializing Structure Variables |
|
|
481 | (1) |
|
|
482 | (2) |
|
|
484 | (1) |
|
|
484 | (1) |
|
A.11.4 Structures and Functions |
|
|
485 | (1) |
|
|
485 | (1) |
|
|
485 | (1) |
|
Passing Structures to Functions |
|
|
486 | (1) |
|
A.11.5 Structures and Unions in MPLAB C18 |
|
|
487 | (4) |
|
Appendix B Debugging 18F Devices |
|
|
491 | (42) |
|
|
491 | (2) |
|
B.1.1 Preliminary Debugging |
|
|
492 | (1) |
|
B.1.2 Debugging the Logic |
|
|
492 | (1) |
|
|
493 | (23) |
|
B.2.1 Debugger-Less Debugging |
|
|
493 | (1) |
|
B.2.2 Code Image Debugging |
|
|
493 | (1) |
|
|
494 | (1) |
|
|
494 | (1) |
|
|
494 | (1) |
|
|
494 | (1) |
|
|
494 | (1) |
|
|
495 | (1) |
|
|
495 | (1) |
|
B.2.4 PIC 18 Special Simulations |
|
|
495 | (1) |
|
|
495 | (1) |
|
|
495 | (1) |
|
|
496 | (1) |
|
|
496 | (1) |
|
|
496 | (1) |
|
|
497 | (1) |
|
|
498 | (1) |
|
|
498 | (1) |
|
|
499 | (1) |
|
|
500 | (1) |
|
|
500 | (1) |
|
|
500 | (1) |
|
Special Function Registers |
|
|
501 | (1) |
|
|
502 | (2) |
|
Watch Window in C Language |
|
|
504 | (1) |
|
B.2.8 Simulator and Tracing |
|
|
504 | (1) |
|
|
505 | (1) |
|
|
506 | (1) |
|
|
507 | (1) |
|
|
508 | (1) |
|
|
509 | (1) |
|
|
510 | (1) |
|
|
510 | (1) |
|
|
510 | (2) |
|
Advanced Pin/Register Tab |
|
|
512 | (1) |
|
|
513 | (1) |
|
|
514 | (1) |
|
|
515 | (1) |
|
|
516 | (10) |
|
B.3.1 Microchip Hardware Programmers/Debuggers |
|
|
516 | (1) |
|
|
516 | (1) |
|
|
517 | (1) |
|
|
517 | (1) |
|
|
518 | (1) |
|
|
519 | (1) |
|
MPLAB PICkit 2 and PICkit 3 |
|
|
519 | (1) |
|
B.3.2 Using Hardware Debuggers |
|
|
519 | (1) |
|
|
520 | (1) |
|
|
520 | (1) |
|
B.3.3 MPLAB ICD2 Debugger Connectivity |
|
|
521 | (1) |
|
Connection from Module to Target |
|
|
522 | (1) |
|
|
523 | (1) |
|
|
523 | (1) |
|
|
524 | (1) |
|
|
525 | (1) |
|
|
526 | (7) |
|
|
526 | (1) |
|
B.4.2 LedFlash_Reloc Program |
|
|
527 | (1) |
|
|
527 | (1) |
|
|
527 | (1) |
|
|
527 | (1) |
|
Configuration Requirements |
|
|
528 | (1) |
|
|
528 | (1) |
|
LedFlash_Reloc.asm Program |
|
|
529 | (2) |
|
|
531 | (2) |
|
Appendix C Building Your Own Circuit Boards |
|
|
533 | (6) |
|
C.1 Drawing the Circuit Diagram |
|
|
533 | (2) |
|
C.2 Printing the PCB Diagram |
|
|
535 | (1) |
|
C.3 Transferring the PCB Image |
|
|
535 | (1) |
|
|
536 | (1) |
|
|
536 | (1) |
|
|
536 | (3) |
|
Appendix D PIC 18 Instruction Set |
|
|
539 | (94) |
|
Appendix E Number Systems and Data Encoding |
|
|
633 | (20) |
|
E.1 Decimal and Binary Systems |
|
|
633 | (1) |
|
E.1.1 Binary Number System |
|
|
633 | (1) |
|
E.1.2 Radix or Base of a Number System |
|
|
634 | (1) |
|
E.2 Decimal versus Binary Numbers |
|
|
634 | (2) |
|
E.2.1 Hexadecimal and Octal |
|
|
635 | (1) |
|
E.3 Character Representations |
|
|
636 | (3) |
|
|
636 | (2) |
|
|
638 | (1) |
|
|
639 | (1) |
|
|
639 | (7) |
|
|
640 | (1) |
|
|
641 | (1) |
|
E.4.3 Sign-Magnitude Representation |
|
|
642 | (1) |
|
E.4.4 Radix Complement Representation |
|
|
643 | (2) |
|
E.4.5 Simplification of Subtraction |
|
|
645 | (1) |
|
E.5 Binary Encoding of Fractional Numbers |
|
|
646 | (7) |
|
E.5.1 Fixed-Point Representations |
|
|
647 | (1) |
|
E.5.2 Floating-Point Representations |
|
|
648 | (1) |
|
E.5.3 Standardized Floating-Point |
|
|
649 | (1) |
|
E.5.4 Binary-Coded Decimals (BCD) |
|
|
650 | (1) |
|
|
650 | (3) |
|
Appendix F Basic Electronics |
|
|
653 | (18) |
|
|
654 | (1) |
|
|
654 | (1) |
|
|
655 | (1) |
|
|
656 | (2) |
|
|
656 | (1) |
|
|
656 | (1) |
|
|
657 | (1) |
|
|
657 | (1) |
|
|
658 | (2) |
|
|
658 | (2) |
|
|
660 | (7) |
|
|
661 | (1) |
|
F.6.2 Revisiting Ohm's Law |
|
|
661 | (1) |
|
F.6.3 Resistors in Series and Parallel |
|
|
662 | (2) |
|
|
664 | (1) |
|
F.6.5 Capacitors in Series and in Parallel |
|
|
665 | (1) |
|
|
666 | (1) |
|
|
667 | (1) |
|
|
667 | (4) |
|
F.7.1 Integrated Circuits |
|
|
668 | (1) |
|
F.7.2 Semiconductor Electronics |
|
|
668 | (1) |
|
F.7.3 P-Type and N-Type Silicon |
|
|
669 | (1) |
|
|
669 | (2) |
Index |
|
671 | |