This book provides a hands-on introductory course on concepts of C programming using a PIC® microcontroller and CCS C compiler. Through a project-based approach, this book provides an easy to understand method of learning the correct and efficient practices to program a PIC® microcontroller in C language. Principles of C programming are introduced gradually, building on skill sets and knowledge. Early chapters emphasize the understanding of C language through experience and exercises, while the latter half of the book covers the PIC® microcontroller, its peripherals, and how to use those peripherals from within C in great detail.
This book demonstrates the programming methodology and tools used by most professionals in embedded design, and will enable you to apply your knowledge and programming skills for any real-life application. Providing a step-by-step guide to the subject matter, this book will encourage you to alter, expand, and customize code for use in your own projects.
Key Features
- A complete introduction to C programming using PIC microcontrollers, with a focus on real-world applications, programming methodology and tools
- Each chapter includes C code project examples, tables, graphs, charts, references, photographs, schematic diagrams, flow charts and compiler compatibility notes to channel your knowledge into real-world examples
- Online materials include presentation slides, extended tests, exercises, quizzes and answers, real-world case studies, videos and weblinks
- Introduction
- Chapter 1: C Overview and Program Structure
- Abstract
- C Source Code
- Comments
- Program Structure
- C Preprocessor Directives
- Functions
- Declarations
- Statements and Expressions
- Time
- Typing Accuracy
- Text Formatting
- Compatibility Notes
- Summary
- Chapter 2: Constants
- Abstract
- Bits, Bytes, Etc.
- Syntax of C Constants
- Tri-Graph Sequences
- Compatibility Notes
- Design Documentation
- Summary
- Chapter 3: Preprocessor Directives
- Abstract
- Standard Preprocessor Directives
- Nonstandard Pragmas
- Summary
- Chapter 4: Data Variable and Types
- Abstract
- Data Types
- Declaring Variables
- Design Documentation
- RAM
- Summary
- Chapter 5: Expressions and Operators
- Abstract
- Mathematical Operators
- Compatibility Notes
- Operator Precedence
- Expression Type and Type Conversion
- Relational Operators
- Binary Bitwise Operators
- Compatibility Notes
- Assignment Operators
- Increment/Decrement Operators
- Other Operators
- Sequence Points
- Expression Examples
- Summary
- Chapter 6: Statements
- Abstract
- Statement Definitions
- Side Effects
- Nesting, Indentation, and Use of Braces
- Design Documentation
- Program Complexity
- Summary
- Chapter 7: Functions
- Abstract
- main() FUNCTION
- Function Definitions
- Function Parameters
- Advanced Features
- Return Values
- Inline Functions
- Nested Functions
- Recursive Functions
- A Little More on Sequence Points
- Well-Structured Programs
- Design Documentation
- Implementation Details
- Summary
- Chapter 8: Arrays
- Abstract
- Array Initializers
- Constant Arrays
- String Variables
- Dimensionless Arrays
- Multidimensional Arrays
- Index Range
- Example Array Usage
- Lookup Tables
- Searching Arrays
- Sorting Arrays
- Summary
- Chapter 9: Structures
- Abstract:
- Structure Nesting and Arrays
- Structure Layout in Memory
- Bit Fields
- Unions
- Example of Structures in a Program
- Summary
- Chapter 10: Memory and Pointers
- Abstract
- Memory
- Address-of Operator
- Indirection Operator
- Forcing a Variable Address
- Pointer Types
- Pointer Math
- Back to Subscripts
- Back to Function Parameters
- Back to Structures
- Function Pointers
- Other Uses for Pointers
- Bad Ideas
- Common Mistakes
- ROM Pointers
- User-Defined Memory
- Compatibility Note
- Over the Hill
- Summary
- Chapter 11: Built-in Functions
- Abstract
- Math
- Memory
- Dynamic Memory
- A Few More Cool Functions
- Variable Argument List
- Text Input/Output
- Implementation Constants
- Compatibility Notes
- Bit and Byte Manipulation
- Non-volatile Memory
- Watchdog Timer
- Delays
- Multiple Clock Speeds
- A Few More Standard Functions
- Coming Up
- Summary
- Chapter 12: Strings
- Abstract
- String Copy and Length
- String Search
- String Compare
- String Manipulation
- String Input and Output
- String Conversion to/from Numbers
- Character Manipulation
- Unicode
- Constant String Management
- Summary
- Chapter 13: Function-like Macros
- Abstract
- Arguments
- Macro Names
- Concatenation Operator
- Stringize Operator
- Variadic Macro Syntax
- Function-Like Macros vs. Inline Functions
- Readability
- Advanced Example
- Debugging Macro Problems
- Summary
- Chapter 14: Conditional Compilation
- Abstract
- Basic Directives
- Relational Expressions
- Special Macros
- Special Defines
- Global Defines
- Strange Errors
- Examples of Conditional Compilation
- Summary
- Chapter 15: PIC® Microcontroller
- Abstract
- PIC® Architecture
- Minimal Hardware Connections
- Device Programming
- Hex Files
- Power-Up Considerations
- Clock Configurations
- Debugging
- Bootloading
- Summary
- Chapter 16: Discrete Input and Output
- Abstract
- Input Voltages
- Drive Current
- Driving More Current
- Open Collector Outputs
- Direction
- Button Input
- Pull-Ups
- Debounce
- Filtering
- Memory-Mapping Ports
- Summary
- Chapter 17: Interrupts
- Abstract
- Simple Interrupt Example
- Where Does the Time Go?
- Debounce Revisited
- It’s Not Always a Good Time to Interrupt
- Why Do We Need Interrupts?
- What is Really Happening
- Handle Your Interrupts Right
- Multiple Interrupt Considerations
- Latency
- Reentrancy
- Compatibility Notes
- Summary
- Chapter 18: Timers/Counters
- Abstract
- Timer Components
- PIC® Specifics
- C Code
- Delay Using Timer
- Precision Loop
- Interrupts
- Virtual Timers
- Summary
- Chapter 19: Advanced Timing
- Abstract
- PWM
- Using the PWM Library
- Capture
- Compare
- Compatibility Notes
- Summary
- Chapter 20: Analog Techniques
- Abstract
- Digital to Analog Conversion
- Analog to Digital Conversion
- Comparator
- Voltage Detect
- Compatibility Notes
- Summary
- Chapter 21: Internal Serial Busses
- Abstract
- Serial Peripheral Interface
- I2C
- Summary
- Chapter 22: External Serial Busses
- Abstract
- RS-232
- Source Code
- UART
- Incoming Data Interrupts
- Outgoing Data Interrupts
- Modem Control Signals
- Hardware Flow Control
- Software Flow Control
- Protocol
- RS-232 Future
- RS-422
- RS-485
- Documentation
- Summary
- Chapter 23: Multi-Tasking
- Abstract
- Preemptive Scheduling
- Dispatcher Scheduling
- Deterministic Scheduling
- Semaphores
- Message Passing
- await()
- Task Management
- Summary
- Chapter 24: Inline Assembly
- Abstract
- Assembly Code with C Code
- Inline Assembly Code
- PIC16/PIC Simple Move Instructions
- Accessing C Variables from Assembly
- PIC16/PIC18 Math Instructions
- PIC16/PIC18 Bit Instructions
- PIC16/18 Branch Instructions
- PIC16/18 Literal Instructions
- Compiler Modifications to the Assembly
- SFR Access
- About the FSR
- What Not To Do
- Optimized Assembly
- PIC24 Instructions
- dsPIC® Instructions
- Summary
- Chapter 25: Debugging
- Abstract
- Overview
- ICSP
- ICSP Jacks
- Breakpoints
- Viewing Memory
- Stepping
- Power Debugging
- Monitor
- Data Streaming
- Real-Time Issues
- Use of a Scope
- Diagnostic Interface
- Record/Playback
- Profile Tool
- Profiling Code
- Design Verification
- Summary
- Bibliography
- Appendix-A
- Appendix-B
- Appendix-C
- Smith: PIC Projects and Applications Using C, Newnes, 2013, 196pp, Paperback, 9780080971513, $39.95/ £23.99/ €28.95
- Di Jasio: Programming 16-Bit PIC Microcontrollers in C, 2nd ed, Newnes, 2011, 396pp, Paperback, 9781856178709, $59.95/ £36.99/ €42.95
- Ibrahim: Designing Embedded Systems with 32-Bit PIC Microcontrollers and MikroC, Newnes, 2013, 462pp, Paperback, 9780080977867, $64.95/ £39.99/ €46.95
Electronic engineering and software engineering students, especially on embedded systems courses; students of computer science and information systems; professional software and electronic engineers; hobbyists.
Wang, Liu, Wang, Stroe, Fernande