Programming 16-Bit PIC Microcontrollers in C (eBook)
400 Seiten
Elsevier Science (Verlag)
978-0-08-047546-2 (ISBN)
. FREE CD-ROM includes source code in C, the Microchip C30 compiler, and MPLAB SIM software
. Includes handy checklists to help readers perform the most common programming and debugging tasks
The new 16-bit PIC24 chip provides embedded programmers with more speed, more memory, and more peripherals than ever before, creating the potential for more powerful cutting-edge PIC designs. This book teaches readers everything they need to know about these chips: how to program them, how to test them, and how to debug them, in order to take full advantage of the capabilities of the new PIC24 microcontroller architecture.
Author Lucio Di Jasio, a PIC expert at Microchip, offers unique insight into this revolutionary technology, guiding the reader step-by-step from 16-bit architecture basics, through even the most sophisticated programming scenarios. This book's common-sense, practical, hands-on approach begins simply and builds up to more challenging exercises, using proven C programming techniques. Experienced PIC users and newcomers to the field alike will benefit from the text's many thorough examples, which demonstrate how to nimbly side-step common obstacles, solve real-world design problems efficiently, and optimize code for all the new PIC24 features.
You will learn about:
. basic timing and I/O operations,
. multitasking using the PIC24 interrupts,
. all the new hardware peripherals
. how to control LCD displays,
. generating audio and video signals,
. accessing mass-storage media,
. how to share files on a mass-storage device with a PC,
. experimenting with the Explorer 16 demo board, debugging methods with MPLAB-SIM and ICD2 tools, and more!
?A Microchip insider tells all on the newest, most powerful PICs ever!
?Condenses typical introductory fluff focusing instead on examples and exercises that show how to solve common, real-world design problems quickly
?Includes handy checklists to help readers perform the most common programming and debugging tasks
?FREE CD-ROM includes source code in C, the Microchip C30 compiler, and MPLAB SIM software, so that readers gain practical, hands-on programming experience
?Check out the author's Web site at http://www.flyingpic24.com for FREE downloads, FAQs, and updates
* A Microchip insider tells all on the newest, most powerful PICs ever! * FREE CD-ROM includes source code in C, the Microchip C30 compiler, and MPLAB SIM software* Includes handy checklists to help readers perform the most common programming and debugging tasksThe new 16-bit PIC24 chip provides embedded programmers with more speed, more memory, and more peripherals than ever before, creating the potential for more powerful cutting-edge PIC designs. This book teaches readers everything they need to know about these chips: how to program them, how to test them, and how to debug them, in order to take full advantage of the capabilities of the new PIC24 microcontroller architecture.Author Lucio Di Jasio, a PIC expert at Microchip, offers unique insight into this revolutionary technology, guiding the reader step-by-step from 16-bit architecture basics, through even the most sophisticated programming scenarios. This book's common-sense, practical, hands-on approach begins simply and builds up to more challenging exercises, using proven C programming techniques. Experienced PIC users and newcomers to the field alike will benefit from the text's many thorough examples, which demonstrate how to nimbly side-step common obstacles, solve real-world design problems efficiently, and optimize code for all the new PIC24 features. You will learn about:* basic timing and I/O operations, * multitasking using the PIC24 interrupts, * all the new hardware peripherals * how to control LCD displays, * generating audio and video signals, * accessing mass-storage media, * how to share files on a mass-storage device with a PC, * experimenting with the Explorer 16 demo board, debugging methods with MPLAB-SIM and ICD2 tools, and more!*A Microchip insider tells all on the newest, most powerful PICs ever! *Condenses typical introductory "e;fluff"e; focusing instead on examples and exercises that show how to solve common, real-world design problems quickly*Includes handy checklists to help readers perform the most common programming and debugging tasks*FREE CD-ROM includes source code in C, the Microchip C30 compiler, and MPLAB SIM software, so that readers gain practical, hands-on programming experience*Check out the author's Web site at http://www.flyingpic24.com for FREE downloads, FAQs, and updates
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
Erscheint lt. Verlag | 16.3.2007 |
---|---|
Sprache | englisch |
Themenwelt | Mathematik / Informatik ► Informatik ► Programmiersprachen / -werkzeuge |
Mathematik / Informatik ► Informatik ► Theorie / Studium | |
Technik ► Elektrotechnik / Energietechnik | |
ISBN-10 | 0-08-047546-9 / 0080475469 |
ISBN-13 | 978-0-08-047546-2 / 9780080475462 |
Haben Sie eine Frage zum Produkt? |
Kopierschutz: Adobe-DRM
Adobe-DRM ist ein Kopierschutz, der das eBook vor Mißbrauch schützen soll. Dabei wird das eBook bereits beim Download auf Ihre persönliche Adobe-ID autorisiert. Lesen können Sie das eBook dann nur auf den Geräten, welche ebenfalls auf Ihre Adobe-ID registriert sind.
Details zum Adobe-DRM
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen eine
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen eine
Geräteliste und zusätzliche Hinweise
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich