Suchen und Finden
Cover
1
Contents
5
Preface
30
Introduction
32
Who should read this book?
32
Structure of the book
33
What this book is not
34
Checklists
34
PART I
20
CHAPTER 1: THE FIRST FLIGHT
5
Flight plan
20
Preflight checklist
21
The flight
21
Compiling and linking
23
Building the first project
24
PORT initialization
26
Retesting PORTA
27
Testing PORTB
27
Post-flight briefing
29
Notes for assembly experts
30
Notes for PIC MCU experts
31
Notes for C experts
31
Tips and tricks
31
Exercises
32
Books
32
Links
32
CHAPTER 2: A LOOP IN THE PATTERN
34
Flight plan
34
Preflight checklist
34
The flight
35
An animated simulation
38
Using the Logic Analyzer
41
Post-flight briefing
43
Notes for assembly experts
44
Notes for PIC microcontroller experts
44
Notes for C experts
44
Tips and tricks
44
Exercises
45
Books
45
Links
45
CHAPTER 3: MORE PATTERN WORK, MORE LOOPS
46
Flight plan
46
Preflight checklist
47
The flight
47
Do Loops
47
Variable declarations
48
for loops
48
More loop examples
49
Arrays
50
A new demo
51
Testing with the Logic Analyzer
53
Using the Explorer16 demonstration board
54
Post-flight briefing
54
Notes for assembly experts
54
Notes for PIC microcontroller experts
55
Notes for C experts
55
Tips and tricks
55
Exercises
57
Books
57
Links
57
CHAPTER 4: NUMB3RS
58
Flight plan
58
Preflight checklist
59
The flight
59
On optimization (or lack thereof)
60
Testing
61
Going long
61
Note on the multiplication of long integers
62
Long long multiplication
62
Floating point
63
Notes for C experts
63
Measuring performance
64
Post-flight briefing
66
Notes for assembly experts
67
Notes for PIC microcontroller experts
68
Tips and tricks
68
Math libraries
68
Complex data types
68
Exercises
69
Books
69
Links
69
CHAPTER 5: INTERRUPTS
70
Flight plan
70
Preflight checklist
70
The flight
71
Nesting of interrupts
74
Traps
74
A template and an example for Timer1 interrupt
75
A real example with Timer1
76
Testing the Timer1 interrupt
78
The secondary oscillator
80
The real-time clock calendar (RTCC)
81
Managing multiple interrupts
81
Post-flight briefing
82
Notes for C experts
82
Notes for assembly experts
82
Notes for PIC microcontroller experts
83
Tips and tricks
83
Exercises
85
Books
85
Links
85
CHAPTER 6: TAKING A LOOK UNDER THE HOOD
86
Flight plan
86
Preflight checklist
86
The fl ight
87
Memory space allocation
88
Program space visibility
89
Investigating memory allocation
90
Looking at the MAP
94
Pointers
96
The heap
97
MPLAB C30 Memory Models
98
Post-flight briefing
98
Notes for C experts
98
Notes for assembly experts
99
Notes for PIC microcontroller experts
99
Tips and tricks
99
Exercises
100
Books
100
Links
100
PART II . FLYING SOLOŽ
106
CHAPTER 7: COMMUNICATION
106
Flight plan
106
Preflight checklist
106
The flight
107
Synchronous serial interfaces
107
Asynchronous serial interfaces
108
Parallel interfaces
109
Synchronous communication using the SPI modules
110
Testing the Read Status Register command
112
Writing to the EEPROM
115
Reading the memory contents
116
A nonvolatile storage library
116
Testing the new NVM library
119
Post-flight briefing
121
Notes for C experts
121
Notes for the experts
121
Notes for PIC microcontroller experts
122
Tips and tricks
122
Exercises
124
Books
124
Links
124
CHAPTER 8: ASYNCHRONOUS COMMUNICATION
126
Flight plan
126
Preflight checklist
126
The flight
127
UART confi guration
128
Sending and receiving data
130
Testing the serial communication routines
131
Building a simple console library
133
Testing a VT100 terminal
135
Using the serial port as a debugging tool
137
The matrix
137
Post-flight briefing
139
Notes for C experts
140
Notes for PIC microcontroller experts
141
Tips and tricks
141
About the ICD2 and UARTs on ICE
141
Exercises
142
Books
142
Links
142
CHAPTER 9: GLASS BLISS
144
Flight plan
145
Pre-flight checklist
145
The flight
145
HD44780 controller compatibility
146
The Parallel Master Port
148
Configuring the PMP for LCD module control
149
A small library of functions to access an LCD display
150
Advanced LCD control
153
Post-flight briefing
155
Notes for C experts
155
Tips and tricks
156
Exercises
157
Books
157
Links
157
CHAPTER 10: IT’S AN ANALOG WORLD
158
Flight plan
158
Preflight checklist
159
The flight
159
The fi rst conversion
161
Automatic sampling timing
162
Developing a demo
163
Developing a game
164
Measuring temperature
166
The breath-alizer game
170
Post-flight briefing
171
Notes for C experts
171
Tips and tricks
172
Exercises
172
Books
172
Links
172
PART III – CROSS-COUNTRY FLYING
178
CHAPTER 11: CAPTURING INPUTS
178
CHAPTER 12: THE DARK SCREEN
218
Flight plan
218
The flight
219
Generating the composite video signal
221
Using the Output Compare modules
225
Memory allocation
228
Image serialization
228
Building the video module
231
Testing the video generator
235
Measuring performance
237
The dark screen
238
A test pattern
239
Plotting
240
A starry night
241
Line drawing
243
Bresenham algorithm
245
Plotting math functions
247
Two-dimensional function visualization
249
Fractals
253
Text
259
Testing the TextOnGPage module
263
Developing a text page video
264
Testing the text page performance
273
Post-flight briefing
277
Tips and tricks
277
Exercises
278
Books
278
Links
278
CHAPTER 13: MASS STORAGE
280
Flight plan
280
The flight
281
The SD/MMC card physical interface
281
Interfacing to the Explorer16 board
282
Starting a new project
283
Selecting the SPI mode of operation
284
Sending commands in SPI mode
284
Completing the SD/MMC card initialization
287
Reading data from an SD/MMC card
288
Writing data to an SD/MMC card
291
Using the SD/MMC interface module
293
Post-flight briefing
297
Tips and tricks
297
Exercises
298
Books
298
Links
298
CHAPTER 14: FILE I/O
300
Flight plan
300
The flight
301
Sectors and Clusters
301
The File Allocation Table (FAT)
302
The Root Directory
303
The treasure hunt
305
Opening a fi le
313
Reading data from a file
322
Closing a file
325
Creating the fileio module
325
Testing fopenM() and freadM()
328
Writing data to a file
330
Closing a file, second take
334
Accessory functions
336
Testing the complete fileio module
340
Code Size
343
Post-flight briefing
343
Tips and tricks
344
Exercises
344
Books
345
Links
345
CHAPTER 15: VOLARE
346
Flight plan
178
The flight
179
The PS/2 communication protocol
180
Interfacing a PIC24 to the PS/2
180
Input Capture
180
Testing the Input Capture method using Stimulus Scripts
185
Testing the PS/2 receive routines
189
The simulation
191
The Simulator Profile
192
Another method – Change Notification
193
Evaluating cost
198
A third method – I/O polling
198
Testing the I/O polling method
203
Cost and efficiency of the solution
205
Completing the interface: adding a FIFO buffer
207
Completing the interface: performing key codes decoding
211
Post-flight briefing
214
Tips and tricks
215
Stalling transmissions from the keyboard – Open-Drain Output Control
215
Exercises
216
Books
216
Links
216
Flight plan
347
The flight
347
Using the PIC24 OC modules in PWM mode
349
Testing the PWM as a D/A converter
351
Producing analog waveforms
352
Reproducing voice messages
355
A media player
356
The WAVE file format
356
The play() function
358
The low level audio routines
364
Testing the WAVE file player
367
Optimizing the fi le I/O
370
LED Profi ling
370
Looking under the hood for more
373
Post-flight briefing
377
Tips and tricks
377
Exercises
377
Books
378
Links
378
About the Author
380
Index
382
Alle Preise verstehen sich inklusive der gesetzlichen MwSt.