Introduction |
|
xxi | |
Acknowledgements |
|
xxv | |
|
Section 1 Getting Started with Embedded Systems |
|
|
1 | (22) |
|
Tiny computers, hidden control |
|
|
3 | (20) |
|
The main idea -- embedded systems in today's world |
|
|
3 | (1) |
|
What is an embedded system? |
|
|
3 | (1) |
|
Some example embedded systems |
|
|
4 | (4) |
|
The domestic refrigerator |
|
|
4 | (1) |
|
|
5 | (1) |
|
The electronic `ping-pong' |
|
|
6 | (1) |
|
The Derbot Autonomous Guided Vehicle |
|
|
7 | (1) |
|
|
8 | (3) |
|
|
9 | (1) |
|
Instruction sets -- CISC and RISC |
|
|
9 | (1) |
|
|
10 | (1) |
|
|
10 | (1) |
|
Microprocessors and microcontrollers |
|
|
11 | (4) |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
13 | (1) |
|
Microcontroller packaging and appearance |
|
|
14 | (1) |
|
Microchip and the PIC microcontroller |
|
|
15 | (2) |
|
|
15 | (1) |
|
PIC microcontrollers today |
|
|
15 | (2) |
|
An introduction to PIC microcontrollers using the 12 Series |
|
|
17 | (3) |
|
|
18 | (2) |
|
What others do -- a Freescale microcontroller |
|
|
20 | (3) |
|
|
22 | (1) |
|
|
22 | (1) |
|
Section 2 Minimum Systems and the PIC® 16F84A |
|
|
23 | (120) |
|
Introducing the PIC® 16 Series and the 16F84A |
|
|
25 | (20) |
|
The main idea -- the PIC 16 Series family |
|
|
25 | (2) |
|
|
25 | (2) |
|
|
27 | (1) |
|
|
27 | (1) |
|
An architecture overview of the 16F84A |
|
|
27 | (2) |
|
|
29 | (1) |
|
A review of memory technologies |
|
|
29 | (3) |
|
|
30 | (1) |
|
EPROM (Erasable Programmable Read-Only Memory) |
|
|
31 | (1) |
|
EEPROM (Electrically Erasable Programmable Read-Only Memory) |
|
|
31 | (1) |
|
|
31 | (1) |
|
|
32 | (5) |
|
The 16F84A program memory |
|
|
32 | (1) |
|
The 16F84A data and Special Function Register memory ('RAM') |
|
|
33 | (2) |
|
|
35 | (1) |
|
|
35 | (2) |
|
|
37 | (1) |
|
Clock oscillator and instruction cycle |
|
|
37 | (1) |
|
|
38 | (1) |
|
|
38 | (2) |
|
What others do -- the Atmel AT89C2051 |
|
|
40 | (1) |
|
Taking things further -- the 16F84A on-chip reset circuit |
|
|
41 | (4) |
|
|
44 | (1) |
|
|
44 | (1) |
|
Parallel ports, power supply and the clock oscillator |
|
|
45 | (20) |
|
The main idea -- parallel input/output |
|
|
46 | (1) |
|
The technical challenge of parallel input/output |
|
|
46 | (6) |
|
Building a parallel interface |
|
|
46 | (3) |
|
Port electrical characteristics |
|
|
49 | (1) |
|
|
49 | (3) |
|
Connecting to the parallel port |
|
|
52 | (3) |
|
|
52 | (1) |
|
|
53 | (2) |
|
The PIC 16F84A parallel ports |
|
|
55 | (4) |
|
|
55 | (1) |
|
|
55 | (1) |
|
Port output characteristics |
|
|
56 | (3) |
|
|
59 | (2) |
|
|
59 | (1) |
|
Practical oscillator considerations |
|
|
60 | (1) |
|
The 16F84A clock oscillator |
|
|
60 | (1) |
|
|
61 | (2) |
|
The need for power, and its sources |
|
|
61 | (1) |
|
16F84A operating conditions |
|
|
62 | (1) |
|
The hardware design of the electronic ping-pong |
|
|
63 | (2) |
|
|
64 | (1) |
|
|
64 | (1) |
|
Starting to program -- an introduction to Assembler |
|
|
65 | (24) |
|
The main idea -- what programs do and how we develop them |
|
|
66 | (3) |
|
The problem of programming and the Assembler compromise |
|
|
66 | (1) |
|
The process of writing in Assembler |
|
|
67 | (1) |
|
The program development process |
|
|
68 | (1) |
|
The PIC 16 Series instruction set, with a little more on the ALU |
|
|
69 | (2) |
|
More on the PIC 16 Series ALU |
|
|
69 | (1) |
|
The PIC 16 Series instruction set -- an introduction |
|
|
70 | (1) |
|
Assemblers and Assembler format |
|
|
71 | (2) |
|
Introducing Assemblers and the Microchip MPASM™ Assembler |
|
|
71 | (1) |
|
|
71 | (1) |
|
|
72 | (1) |
|
|
72 | (1) |
|
|
73 | (3) |
|
A simple data transfer program |
|
|
73 | (3) |
|
Adopting a development environment |
|
|
76 | (1) |
|
|
76 | (1) |
|
|
76 | (1) |
|
|
77 | (1) |
|
An introductory MPLAB tutorial |
|
|
77 | (4) |
|
|
77 | (2) |
|
|
79 | (1) |
|
|
80 | (1) |
|
An introduction to simulation |
|
|
81 | (2) |
|
|
81 | (1) |
|
|
81 | (1) |
|
Viewing microcontroller features |
|
|
82 | (1) |
|
Resetting and running the program |
|
|
82 | (1) |
|
Downloading the program to a microcontroller |
|
|
83 | (3) |
|
What others do -- a brief comparison of CISC and RISC instruction sets |
|
|
86 | (1) |
|
Taking things further -- the 16 Series instruction set format |
|
|
87 | (2) |
|
|
88 | (1) |
|
|
88 | (1) |
|
Building Assembler programs |
|
|
89 | (31) |
|
The main idea -- building structured programs |
|
|
89 | (3) |
|
|
89 | (2) |
|
|
91 | (1) |
|
Flow control -- branching and subroutines |
|
|
92 | (3) |
|
Conditional branching and working with bits |
|
|
92 | (2) |
|
Subroutines and the Stack |
|
|
94 | (1) |
|
Generating time delays and intervals |
|
|
95 | (2) |
|
|
97 | (4) |
|
Indirect addressing and the File Select Register |
|
|
97 | (1) |
|
|
98 | (1) |
|
Example program with delays and look-up table |
|
|
99 | (2) |
|
Introducing logical instructions |
|
|
101 | (1) |
|
Introducing arithmetic instructions and the Carry flag |
|
|
102 | (4) |
|
|
102 | (1) |
|
Using subtract instructions |
|
|
102 | (1) |
|
An arithmetic program example |
|
|
102 | (2) |
|
Using indirect addressing to save the Fibonacci series |
|
|
104 | (2) |
|
Taming Assembler complexity |
|
|
106 | (3) |
|
|
106 | (1) |
|
|
107 | (1) |
|
MPLAB special instructions |
|
|
108 | (1) |
|
More use of the MPLAB simulator |
|
|
109 | (3) |
|
|
109 | (1) |
|
|
110 | (1) |
|
|
110 | (2) |
|
|
112 | (4) |
|
A structure for the ping-pong program |
|
|
112 | (3) |
|
Exploring the ping-pong program code |
|
|
115 | (1) |
|
Simulating the ping-pong program -- tutorial |
|
|
116 | (2) |
|
Setting up input stimulus |
|
|
116 | (1) |
|
Setting up the Watch window |
|
|
116 | (1) |
|
|
116 | (1) |
|
|
117 | (1) |
|
|
117 | (1) |
|
|
117 | (1) |
|
|
117 | (1) |
|
|
117 | (1) |
|
Debugging the full program |
|
|
118 | (1) |
|
What others do -- graphical simulators |
|
|
118 | (2) |
|
|
119 | (1) |
|
|
119 | (1) |
|
Working with time: interrupts, counters and timers |
|
|
120 | (23) |
|
The main idea -- interrupts |
|
|
121 | (4) |
|
|
121 | (1) |
|
The 16F84A interrupt structure |
|
|
122 | (2) |
|
The CPU response to an interrupt |
|
|
124 | (1) |
|
|
125 | (6) |
|
Programming with a single interrupt |
|
|
125 | (1) |
|
Moving to multiple interrupts -- identifying the source |
|
|
126 | (1) |
|
Stopping interrupts from wrecking your program 1 -- context saving |
|
|
127 | (3) |
|
Stopping interrupts from wrecking your program 2 -- critical regions and masking |
|
|
130 | (1) |
|
The main idea -- counters and timers |
|
|
131 | (5) |
|
The digital counter reviewed |
|
|
131 | (1) |
|
|
132 | (2) |
|
The 16F84A Timer 0 module |
|
|
134 | (2) |
|
Applying the 16F84A Timer 0, with examples using the electronic ping-pong |
|
|
136 | (2) |
|
|
136 | (1) |
|
Hardware-generated delays |
|
|
137 | (1) |
|
|
138 | (1) |
|
|
139 | (1) |
|
|
140 | (1) |
|
Taking things further -- interrupt latency |
|
|
141 | (2) |
|
|
142 | (1) |
|
Section 3 Larger Systems and the PIC® 16F873A |
|
|
143 | (190) |
|
Larger systems and the PIC® 16F873A |
|
|
145 | (39) |
|
The main idea -- the PIC 16F87XA |
|
|
146 | (1) |
|
The 16F873A block diagram and CPU |
|
|
146 | (4) |
|
|
146 | (1) |
|
|
147 | (3) |
|
|
150 | (1) |
|
16F873A memory and memory maps |
|
|
150 | (5) |
|
The 16F873A program memory |
|
|
150 | (2) |
|
The 16F873A data memory and Special Function Registers |
|
|
152 | (2) |
|
|
154 | (1) |
|
`Special' memory operations |
|
|
155 | (3) |
|
Accessing EEPROM and program memory |
|
|
155 | (1) |
|
In-Circuit Serial Programming (ICSP™) |
|
|
156 | (2) |
|
|
158 | (3) |
|
|
158 | (1) |
|
|
159 | (2) |
|
Interrupt identification and context saving |
|
|
161 | (1) |
|
The 16F873A oscillator, reset and power supply |
|
|
161 | (1) |
|
|
161 | (1) |
|
|
161 | (1) |
|
The 16F873A parallel ports |
|
|
161 | (4) |
|
|
163 | (1) |
|
|
164 | (1) |
|
|
164 | (1) |
|
Test, commission and diagnostic tools |
|
|
165 | (6) |
|
The challenge of testing an embedded system |
|
|
165 | (2) |
|
Oscilloscopes and logic analysers |
|
|
167 | (3) |
|
|
170 | (1) |
|
|
170 | (1) |
|
The Microchip in-circuit debugger (ICD 2) |
|
|
171 | (1) |
|
Applying the 16F873A: the Derbot AGV |
|
|
172 | (4) |
|
Power supply, oscillator and reset |
|
|
172 | (1) |
|
Use of the parallel ports |
|
|
173 | (1) |
|
|
174 | (2) |
|
Downloading, testing and running a simple program with ICD 2 |
|
|
176 | (4) |
|
|
176 | (2) |
|
|
178 | (1) |
|
Setting the configuration bits within the program |
|
|
179 | (1) |
|
Taking things further -- the 16F874A/16F877A Ports D and E |
|
|
180 | (4) |
|
|
182 | (1) |
|
|
183 | (1) |
|
The human and physical interfaces |
|
|
184 | (41) |
|
The main idea -- the human interface |
|
|
184 | (3) |
|
|
187 | (6) |
|
|
187 | (1) |
|
Design example: use of keypad in Derbot hand controller |
|
|
188 | (5) |
|
|
193 | (6) |
|
LED arrays: seven-segment displays |
|
|
193 | (1) |
|
Design example: the Derbot hand controller seven-segment display |
|
|
194 | (5) |
|
|
199 | (4) |
|
The HD44780 LCD driver and its derivatives |
|
|
199 | (1) |
|
Design example: use of LCD display in Derbot hand controller |
|
|
200 | (3) |
|
The main idea -- interfacing to the physical world |
|
|
203 | (1) |
|
|
203 | (4) |
|
|
204 | (1) |
|
Light-dependent resistors |
|
|
204 | (1) |
|
|
205 | (1) |
|
The opto-sensor applied as a shaft encoder |
|
|
205 | (2) |
|
|
207 | (1) |
|
|
207 | (5) |
|
16F873A input characteristics |
|
|
207 | (1) |
|
Ensuring legal logic levels, and input protection |
|
|
208 | (4) |
|
|
212 | (1) |
|
Actuators: motors and servos |
|
|
212 | (3) |
|
|
212 | (2) |
|
Angular positioning: the `servo' |
|
|
214 | (1) |
|
|
215 | (5) |
|
|
215 | (2) |
|
Simple switching on the Derbot |
|
|
217 | (1) |
|
Reversible switching: the H-bridge |
|
|
218 | (2) |
|
Motor switching on the Derbot |
|
|
220 | (1) |
|
|
220 | (2) |
|
Applying sensors and actuators -- a `blind' navigation Derbot program |
|
|
222 | (3) |
|
|
223 | (1) |
|
|
223 | (2) |
|
|
225 | (38) |
|
The main ideas -- taking counting and timing further |
|
|
225 | (1) |
|
The 16F87XA Timer 0 and Timer 1 |
|
|
226 | (6) |
|
|
226 | (1) |
|
|
226 | (2) |
|
Application of Timer 0 and Timer 1 as counters for Derbot odometry |
|
|
228 | (3) |
|
Using Timer 0 and Timer 1 to generate repetitive interrupts |
|
|
231 | (1) |
|
The 16F87XA Timer 2, comparator and PR2 register |
|
|
232 | (3) |
|
|
232 | (2) |
|
The PR2 register, comparator and postscaler |
|
|
234 | (1) |
|
The capture/compare/PWM (CCP) modules |
|
|
235 | (2) |
|
A capture/compare/PWM overview |
|
|
235 | (1) |
|
|
235 | (2) |
|
|
237 | (1) |
|
|
237 | (7) |
|
|
237 | (2) |
|
Generating PWM signals in hardware -- the 16F87XA PWM |
|
|
239 | (2) |
|
PWM applied in the Derbot for motor control |
|
|
241 | (3) |
|
Generating PWM in software |
|
|
244 | (5) |
|
An example of software-generated PWM |
|
|
245 | (3) |
|
Further Assembler directives for memory definition and branching |
|
|
248 | (1) |
|
PWM used for digital-to-analog conversion |
|
|
249 | (3) |
|
An example of PWM used for digital-to-analog conversion |
|
|
249 | (3) |
|
|
252 | (3) |
|
The principle of frequency measurement |
|
|
252 | (1) |
|
Frequency (speed) measurement in the Derbot |
|
|
252 | (3) |
|
Speed control applied to the Derbot |
|
|
255 | (3) |
|
|
258 | (2) |
|
|
260 | (1) |
|
Where do we go from here? |
|
|
261 | (1) |
|
|
262 | (1) |
|
|
262 | (1) |
|
|
262 | (1) |
|
|
263 | (41) |
|
The main idea -- introducing serial |
|
|
263 | (2) |
|
Simple serial links -- synchronous data communication |
|
|
265 | (2) |
|
|
265 | (1) |
|
Implementing synchronous serial I/O in the microcontroller |
|
|
266 | (1) |
|
Microwire and SPI (Serial Peripheral Interface) |
|
|
266 | (1) |
|
Introducing multiple nodes |
|
|
267 | (1) |
|
The 16F87XA Master Synchronous Serial Port (MSSP) module in SPI mode |
|
|
267 | (6) |
|
|
268 | (1) |
|
|
268 | (2) |
|
|
270 | (1) |
|
|
271 | (2) |
|
|
273 | (2) |
|
The limitations of Microwire and SPI, and of simple synchronous serial transfer |
|
|
275 | (1) |
|
Enhancing synchronous serial, and the Inter-Integrated Circuit bus |
|
|
275 | (2) |
|
Main I2C features and physical interconnection |
|
|
275 | (1) |
|
|
275 | (1) |
|
I2C signal characteristics |
|
|
276 | (1) |
|
The MSSP configured for I2C |
|
|
277 | (9) |
|
The MSSP I2C registers and their preliminary use |
|
|
277 | (4) |
|
The MSSP in I2C Slave mode |
|
|
281 | (2) |
|
The MSSP in I2C Master mode |
|
|
283 | (3) |
|
I2C applied in the Derbot AGV |
|
|
286 | (7) |
|
The Derbot hand controller as a serial node |
|
|
286 | (1) |
|
|
286 | (4) |
|
The hand controller as an I2C slave |
|
|
290 | (2) |
|
Evaluation of the Derbot I2C programs |
|
|
292 | (1) |
|
Evaluation of synchronous serial data communication and an introduction to asynchronous |
|
|
293 | (2) |
|
|
293 | (1) |
|
Synchronising serial data -- without an incoming clock |
|
|
293 | (2) |
|
The 16F87XA Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART) |
|
|
295 | (8) |
|
|
295 | (1) |
|
The USART asynchronous transmitter |
|
|
295 | (3) |
|
The USART baud rate generator |
|
|
298 | (1) |
|
The USART asynchronous receiver |
|
|
299 | (1) |
|
|
300 | (2) |
|
Using address detection with the USART receive mode |
|
|
302 | (1) |
|
The USART in synchronous mode |
|
|
302 | (1) |
|
Implementing serial without a serial port -- `bit banging' |
|
|
303 | (1) |
|
|
303 | (1) |
|
|
303 | (1) |
|
|
303 | (1) |
|
Data acquisition and manipulation |
|
|
304 | (29) |
|
The main idea -- analog and digital quantities, their acquisition and use |
|
|
304 | (1) |
|
The data acquisition system |
|
|
305 | (7) |
|
The analog-to-digital converter |
|
|
306 | (2) |
|
Signal conditioning -- amplification and filtering |
|
|
308 | (1) |
|
|
308 | (1) |
|
Sample and hold, and acquisition time |
|
|
309 | (1) |
|
Timing and microprocessor control |
|
|
310 | (1) |
|
Data acquisition in the microcontroller environment |
|
|
311 | (1) |
|
The PIC® 16F87XA ADC module |
|
|
312 | (7) |
|
Overview and block diagram |
|
|
312 | (1) |
|
|
313 | (4) |
|
|
317 | (1) |
|
Calculating acquisition time |
|
|
318 | (1) |
|
|
319 | (1) |
|
Trading off conversion speed and resolution |
|
|
319 | (1) |
|
Applying the ADC in the Derbot light meter program |
|
|
319 | (2) |
|
|
319 | (1) |
|
|
320 | (1) |
|
|
321 | (1) |
|
Some simple data manipulation techniques |
|
|
321 | (5) |
|
Fixed- and floating-point arithmetic |
|
|
322 | (1) |
|
Binary to Binary Coded Decimal conversion |
|
|
323 | (1) |
|
|
324 | (1) |
|
Scaling and the Derbot light meter example |
|
|
324 | (2) |
|
Using the voltage reference for scaling |
|
|
326 | (1) |
|
The Derbot light-seeking program |
|
|
326 | (1) |
|
|
327 | (2) |
|
Review of comparator action |
|
|
327 | (2) |
|
The 16F87XA comparators and voltage reference |
|
|
329 | (1) |
|
Applying the Derbot circuit for measurement purposes |
|
|
329 | (3) |
|
The electronic tape measure |
|
|
329 | (2) |
|
|
331 | (1) |
|
|
331 | (1) |
|
Other measurement systems |
|
|
331 | (1) |
|
Configuring the Derbot AGV as a light-seeking robot |
|
|
332 | (1) |
|
|
332 | (1) |
|
|
332 | (1) |
|
Section 4 Smarter Systems and the PIC® 18FXX2 |
|
|
333 | (178) |
|
Smarter systems and the PIC® 18FXX2 |
|
|
335 | (33) |
|
The main idea -- the PIC 18 Series and the 18FXX2 |
|
|
336 | (1) |
|
The 18F2X2 block diagram and Status register |
|
|
337 | (3) |
|
The 18 Series instruction set |
|
|
340 | (5) |
|
Instructions which are unchanged |
|
|
344 | (1) |
|
Instructions which have been upgraded |
|
|
344 | (1) |
|
New, variant, instructions |
|
|
345 | (1) |
|
|
345 | (1) |
|
Data memory and Special Function Registers |
|
|
345 | (2) |
|
|
345 | (2) |
|
|
347 | (1) |
|
Indirect addressing and accessing tables in data memory |
|
|
347 | (1) |
|
|
347 | (5) |
|
|
349 | (1) |
|
|
349 | (1) |
|
Upgrading from the 16 Series and computed goto instructions |
|
|
349 | (1) |
|
The Configuration registers |
|
|
350 | (2) |
|
|
352 | (1) |
|
Automatic Stack operations |
|
|
352 | (1) |
|
Programmer access to the Stack |
|
|
352 | (1) |
|
|
352 | (1) |
|
|
353 | (5) |
|
An interrupt structure overview |
|
|
353 | (1) |
|
The interrupt sources, their enabling and prioritisation |
|
|
353 | (1) |
|
Overall interrupt prioritisation enabling |
|
|
354 | (1) |
|
|
354 | (1) |
|
Other aspects of the interrupt logic |
|
|
355 | (1) |
|
|
355 | (1) |
|
Context saving with interrupts |
|
|
356 | (2) |
|
|
358 | (2) |
|
|
358 | (1) |
|
|
358 | (2) |
|
|
360 | (4) |
|
LP, XT, HS and RC oscillator modes |
|
|
362 | (1) |
|
EC, ECIO and RCIO oscillator modes |
|
|
363 | (1) |
|
|
363 | (1) |
|
|
363 | (1) |
|
Introductory programming with the 18F242 |
|
|
364 | (4) |
|
Using the MPLAB IDE for the 18 Series |
|
|
364 | (1) |
|
|
365 | (2) |
|
|
367 | (1) |
|
|
367 | (1) |
|
The PIC® 18FXX2 peripherals |
|
|
368 | (18) |
|
The main idea -- the 18FXX2 peripherals |
|
|
368 | (1) |
|
|
369 | (2) |
|
|
369 | (1) |
|
|
369 | (2) |
|
|
371 | (1) |
|
|
371 | (1) |
|
|
371 | (5) |
|
|
371 | (2) |
|
|
373 | (1) |
|
|
373 | (1) |
|
|
373 | (3) |
|
|
376 | (1) |
|
The capture/compare/PWM (CCP) modules |
|
|
376 | (2) |
|
|
376 | (1) |
|
|
376 | (1) |
|
|
377 | (1) |
|
|
378 | (1) |
|
|
378 | (2) |
|
|
379 | (1) |
|
|
379 | (1) |
|
|
380 | (1) |
|
The analog-to-digital converter (ADC) |
|
|
380 | (1) |
|
|
380 | (2) |
|
Applying the 18 Series in the Derbot-18 |
|
|
382 | (1) |
|
The 18F2420 and the extended instruction set |
|
|
383 | (3) |
|
|
383 | (1) |
|
The extended instruction set |
|
|
384 | (1) |
|
|
384 | (1) |
|
|
385 | (1) |
|
|
385 | (1) |
|
|
386 | (23) |
|
|
387 | (1) |
|
|
387 | (7) |
|
|
387 | (1) |
|
|
388 | (1) |
|
Laying out the program -- declarations, statements, comments and space |
|
|
388 | (2) |
|
|
390 | (1) |
|
|
391 | (1) |
|
|
392 | (1) |
|
|
392 | (1) |
|
Control of program flow, and the while keyword |
|
|
393 | (1) |
|
The C preprocessor and its directives |
|
|
394 | (1) |
|
Use of libraries, and the Standard Library |
|
|
394 | (1) |
|
|
394 | (1) |
|
|
395 | (1) |
|
|
396 | (1) |
|
|
396 | (1) |
|
|
396 | (4) |
|
The Linker and Linker Scripts |
|
|
396 | (1) |
|
Linking header and library files |
|
|
397 | (1) |
|
|
397 | (1) |
|
|
398 | (2) |
|
|
400 | (1) |
|
A second C example -- the Fibonacci program |
|
|
401 | (2) |
|
Program preliminaries -- more on declaring variables |
|
|
402 | (1) |
|
|
403 | (1) |
|
Labels and the goto keyword |
|
|
403 | (1) |
|
Simulating the Fibonacci program |
|
|
403 | (1) |
|
|
403 | (3) |
|
Hardware peripheral functions |
|
|
404 | (1) |
|
The software peripheral library |
|
|
404 | (1) |
|
The general software library |
|
|
405 | (1) |
|
|
406 | (1) |
|
|
406 | (3) |
|
|
407 | (1) |
|
|
407 | (2) |
|
C and the embedded environment |
|
|
409 | (14) |
|
The main idea -- adapting C to the embedded environment |
|
|
409 | (1) |
|
Controlling and branching on bit values |
|
|
409 | (4) |
|
Controlling individual bits |
|
|
411 | (1) |
|
The if and if--else conditional branch structures |
|
|
411 | (1) |
|
Setting the configuration bits |
|
|
412 | (1) |
|
Simulating and running the example program |
|
|
412 | (1) |
|
|
413 | (2) |
|
|
413 | (1) |
|
|
414 | (1) |
|
Function calls and data passing |
|
|
414 | (1) |
|
Library delay functions, and Delay10KTCYx( ) |
|
|
415 | (1) |
|
More branching and looping |
|
|
415 | (2) |
|
|
415 | (1) |
|
|
416 | (1) |
|
Using the timer and PWM peripherals |
|
|
417 | (6) |
|
Using the timer peripherals |
|
|
420 | (1) |
|
|
421 | (1) |
|
|
421 | (1) |
|
|
422 | (1) |
|
Acquiring and using data with C |
|
|
423 | (21) |
|
The main idea -- using C for data manipulation |
|
|
423 | (1) |
|
|
423 | (8) |
|
The light-seeking program structure |
|
|
427 | (1) |
|
|
428 | (1) |
|
|
429 | (1) |
|
Simulating the light-seeking program |
|
|
429 | (2) |
|
Pointers, arrays and strings |
|
|
431 | (6) |
|
|
431 | (1) |
|
|
432 | (1) |
|
Using pointers with arrays |
|
|
432 | (1) |
|
|
433 | (1) |
|
An example program: using pointers, arrays and strings |
|
|
433 | (1) |
|
A word on evaluating the while condition |
|
|
434 | (1) |
|
Simulating the program example |
|
|
435 | (2) |
|
|
437 | (3) |
|
|
437 | (2) |
|
Use of ++ and -- operators |
|
|
439 | (1) |
|
Formatting data for display |
|
|
440 | (4) |
|
Overview of example program |
|
|
440 | (2) |
|
Using library functions for data formatting |
|
|
442 | (1) |
|
|
442 | (1) |
|
|
443 | (1) |
|
More C and the wider C environment |
|
|
444 | (22) |
|
The main idea -- more C and the wider C environment |
|
|
444 | (1) |
|
|
445 | (1) |
|
Controlling memory allocation |
|
|
446 | (2) |
|
Memory allocation pragmas |
|
|
447 | (1) |
|
Setting the Configuration Words |
|
|
447 | (1) |
|
|
448 | (1) |
|
The Interrupt Service Routine |
|
|
448 | (1) |
|
Locating and identifying the ISR |
|
|
449 | (1) |
|
Example with interrupt on overflow -- flashing LEDs on the Derbot |
|
|
449 | (4) |
|
|
450 | (1) |
|
Using interrupts, and the ISR action |
|
|
451 | (1) |
|
Simulating the flashing LEDs program |
|
|
452 | (1) |
|
Storage classes and their application |
|
|
453 | (3) |
|
|
453 | (1) |
|
|
454 | (1) |
|
|
454 | (1) |
|
|
455 | (1) |
|
Working with 18 Series memory |
|
|
455 | (1) |
|
|
455 | (1) |
|
|
456 | (3) |
|
|
456 | (1) |
|
|
457 | (1) |
|
|
457 | (2) |
|
Structures, unions and bit-fields |
|
|
459 | (1) |
|
Processor-specific header files |
|
|
460 | (2) |
|
|
460 | (1) |
|
Assembler utilities in the header file |
|
|
461 | (1) |
|
Taking things further -- the MPLAB Linker and the .map file |
|
|
462 | (4) |
|
|
462 | (1) |
|
|
462 | (2) |
|
|
464 | (1) |
|
|
465 | (1) |
|
|
465 | (1) |
|
Multi-tasking and the Real Time Operating System |
|
|
466 | (14) |
|
The main ideas -- the challenge of multi-tasking and real time |
|
|
466 | (3) |
|
Multi-tasking -- tasks, priorities and deadlines |
|
|
467 | (1) |
|
|
468 | (1) |
|
Achieving multi-tasking with sequential programming |
|
|
469 | (3) |
|
Evaluating the super loop |
|
|
469 | (1) |
|
Time-triggered and event-triggered tasks |
|
|
469 | (1) |
|
Using interrupts for prioritisation -- the foreground/background structure |
|
|
469 | (1) |
|
Introducing a `clock tick' to synchronise program activity |
|
|
470 | (1) |
|
A general-purpose `operating system' |
|
|
471 | (1) |
|
The limits of sequential programming when multi-tasking |
|
|
471 | (1) |
|
The Real Time Operating System (RTOS) |
|
|
472 | (1) |
|
Scheduling and the scheduler |
|
|
473 | (4) |
|
|
473 | (1) |
|
Round robin scheduling and context switching |
|
|
473 | (1) |
|
|
474 | (1) |
|
Prioritised pre-emptive scheduling |
|
|
475 | (1) |
|
|
476 | (1) |
|
The role of interrupts in scheduling |
|
|
477 | (1) |
|
|
477 | (1) |
|
|
477 | (1) |
|
Writing tasks and setting priority |
|
|
478 | (1) |
|
Data and resource protection -- the semaphore |
|
|
478 | (1) |
|
Where do we go from here? |
|
|
479 | (1) |
|
|
479 | (1) |
|
|
479 | (1) |
|
The Salvo™ Real Time Operating System |
|
|
480 | (31) |
|
The main idea -- Salvo, an example RTOS |
|
|
480 | (2) |
|
|
480 | (1) |
|
Salvo versions and references |
|
|
481 | (1) |
|
Configuring the Salvo application |
|
|
482 | (1) |
|
Building Salvo applications -- the library build |
|
|
482 | (1) |
|
|
482 | (1) |
|
|
483 | (1) |
|
|
483 | (2) |
|
Initialisation and scheduling |
|
|
484 | (1) |
|
|
485 | (1) |
|
|
485 | (6) |
|
Program overview and the main function |
|
|
487 | (1) |
|
|
488 | (1) |
|
Creating a Salvo/C18 project |
|
|
488 | (1) |
|
Setting the configuration file |
|
|
489 | (1) |
|
Building the Salvo example |
|
|
489 | (1) |
|
Simulating the Salvo program |
|
|
490 | (1) |
|
Using interrupts, delays and semaphores with Salvo |
|
|
491 | (8) |
|
An example program using an interrupt-based clock tick |
|
|
492 | (2) |
|
Selecting the library and configuration |
|
|
494 | (1) |
|
Using interrupts and establishing the clock tick |
|
|
494 | (2) |
|
|
496 | (1) |
|
|
496 | (1) |
|
|
497 | (2) |
|
|
499 | (1) |
|
Using Salvo messages and increasing RTOS complexity |
|
|
499 | (1) |
|
A program example with messages |
|
|
500 | (9) |
|
Selecting the library and configuration |
|
|
505 | (1) |
|
|
505 | (1) |
|
|
505 | (1) |
|
|
506 | (1) |
|
The use of interrupts, and the ISRs |
|
|
507 | (2) |
|
Simulating or running the program |
|
|
509 | (1) |
|
|
509 | (2) |
|
|
510 | (1) |
|
|
510 | (1) |
|
Section 5 Techniques of Connectivity and Networking |
|
|
511 | (16) |
|
Connectivity and networks |
|
|
513 | (14) |
|
The main idea -- networking and connectivity |
|
|
513 | (2) |
|
|
514 | (1) |
|
|
515 | (1) |
|
The IrDA and the PIC microcontroller |
|
|
515 | (1) |
|
|
516 | (2) |
|
|
516 | (1) |
|
|
517 | (1) |
|
Zigbee and the PIC microcontroller |
|
|
517 | (1) |
|
Controller Area Network (CAN) and Local Interconnect Network (LIN) |
|
|
518 | (4) |
|
Controller Area Network (CAN) |
|
|
518 | (2) |
|
CAN and the PIC microcontroller |
|
|
520 | (1) |
|
Local Interconnect Network (LIN) |
|
|
520 | (1) |
|
LIN and the PIC microcontroller |
|
|
521 | (1) |
|
Embedded systems and the Internet |
|
|
522 | (1) |
|
Connecting to the Internet with the PIC microcontroller |
|
|
523 | (1) |
|
|
523 | (4) |
|
|
524 | (1) |
|
|
524 | (3) |
Appendix 1 The PIC® 16 Series instruction set |
|
527 | (1) |
Appendix 2 The electronic ping-pong |
|
528 | (5) |
Appendix 3 The Derbot AGV -- hardware design details |
|
533 | (4) |
Appendix 4 Some basics of Autonomous Guided Vehicles |
|
537 | (4) |
Appendix 5 PIC® 18 Series instruction set (non-extended) |
|
541 | (3) |
Appendix 6 Essentials of C |
|
544 | (5) |
Index |
|
549 | |