Professional Documents
Culture Documents
Projects in C
Dogan Ibrahim
4 3 2
Contents
Preface............................................................................................. xiii
Acknowledgments ................................................................................ xv
Chapter 1: Microcomputer Systems.......................................................... 1
1.1 Introduction..................................................................................................1
1.2 Microcontroller Systems ...............................................................................1
1.2.1 RAM .................................................................................................5
1.2.2 ROM .................................................................................................5
1.2.3 PROM ...............................................................................................5
1.2.4 EPROM.............................................................................................6
1.2.5 EEPROM ..........................................................................................6
1.2.6 Flash EEPROM .................................................................................6
1.3 Microcontroller Features...............................................................................6
1.3.1 Supply Voltage ..................................................................................7
1.3.2 The Clock..........................................................................................7
1.3.3 Timers ...............................................................................................7
1.3.4 Watchdog ..........................................................................................8
1.3.5 Reset Input ........................................................................................8
1.3.6 Interrupts ...........................................................................................8
1.3.7 Brown-out Detector ...........................................................................9
1.3.8 Analog-to-Digital Converter ...............................................................9
1.3.9 Serial Input-Output ............................................................................9
1.3.10 EEPROM Data Memory ..................................................................10
1.3.11 LCD Drivers....................................................................................10
1.3.12 Analog Comparator..........................................................................10
1.3.13 Real-time Clock...............................................................................11
1.3.14 Sleep Mode .....................................................................................11
1.3.15 Power-on Reset................................................................................11
www.newnespress.com
vi
Contents
1.4
1.5
1.6
1.7
1.8
1.9
1.10
1.11
1.12
1.13
1.14
1.15
1.16
1.17
1.18
1.19
1.20
1.21
1.22
1.23
1.24
1.25
www.newnespress.com
Contents
vii
www.newnespress.com
viii
Contents
www.newnespress.com
Contents
ix
www.newnespress.com
Contents
8.5 PIC18 Microcontroller USB Bus Interface ................................................ 427
8.6 mikroC Language USB Bus Library Functions ......................................... 429
Project 8.1USB-Based Microcontroller Output Port ..................................... 430
Project 8.2USB-Based Microcontroller Input/Output .................................... 456
Project 8.3USB-Based Ambient Pressure Display on the PC ........................ 464
www.newnespress.com
Contents
xi
Index...............................................................................................541
www.newnespress.com
Preface
www.newnespress.com
xiv
Preface
Chapter 4 covers advanced features of the mikroC language. Topics such as built-in
functions and libraries are discussed in this chapter with examples.
Chapter 5 explores the various software and hardware development tools for the
PIC18F series of microcontrollers. Various commercially available development kits
as well as development tools such as simulators, emulators, and in-circuit debuggers
are described with examples.
Chapter 6 provides some simple projects using the PIC18F series of microcontrollers
and the mikroC compiler. All the projects are based on the PIC18F452 microcontroller, and all of them have been tested. This chapter should be useful for those
who are new to PIC microcontrollers as well as for those who want to extend their
knowledge of programming PIC18F microcontrollers using the mikroC language.
Chapter 7 covers the use of SD memory cards in PIC18F microcontroller projects.
The theory of these cards is given with real working examples.
Chapter 8 reviews the popular USB bus, discussing the basic theory of this bus
system with real working projects that illustrate how to design PIC18F-based projects
communicating with a PC over the USB bus.
The CAN bus is currently used in many automotive applications. Chapter 9 presents
a brief theory of this bus and also discusses the design of PIC18F microcontrollerbased projects with CAN bus interface.
Chapter 10 is about real-time operating systems (RTOS) and multi-tasking. The
basic theory of RTOS systems is described and simple multi-tasking applications are
given.
The CD-ROM that accompanies this book contains all the program source files and
HEX files for the projects described in the book. In addition, a 2K size limited version
of the mikroC compiler is included on the CD-ROM.
Dogan Ibrahim
London, 2007
www.newnespress.com
Acknowledgments
The following material is reproduced in this book with the kind permission of the
respective copyright holders and may not be reprinted, or reproduced in any other way,
without their prior consent.
Figures 2.12.10, 2.222.36, 2.37, 2.38, 2.412.55, 5.25.4, 5.17, 5.20, 8.8, and 9.13,
and Table 2.2 are taken from Microchip Technology Inc. data sheets PIC18FXX2
(DS39564C) and PIC18F2455/2550/4455/4550 (DS39632D).
Figure 5.5 is taken from the web site of BAJI Labs.
Figures 5.65.8 are taken from the web site of Shuan Shizu Ent. Co., Ltd.
Figures 5.9, 5.13, 5.18 are taken from the web site of Custom Computer Services Inc.
Figures 5.10, 5.19, and 6.43 are taken from the web site of mikroElektronika Ltd.
Figure 5.11 is taken from the web site of Futurlec.
Figure 5.21 is taken from the web site of Smart Communications Ltd.
Figure 5.22 is taken from the web site of RF Solutions.
Figure 5.23 is taken from the web site of Phyton.
Figures 5.1 and 5.14 are taken from the web site of microEngineering Labs Inc.
Figure 5.16 is taken from the web site of Kanda Systems.
Thanks is due to mikroElektronika Ltd. for their technical support and for permission to
include a limited size mikroC compiler on the CD-ROM that accompanies this book.
PICW, PICSTARTW, and MPLABW are all registered trademarks of Microchip
Technology Inc.
www.newnespress.com