INTRODUCTORY PROGRAMS WITH THE 32BIT PIC MICROCONTROLLER : a line-by line code analysis... and reference guide for embedded programming in c
معرفی کتاب «INTRODUCTORY PROGRAMS WITH THE 32BIT PIC MICROCONTROLLER : a line-by line code analysis... and reference guide for embedded programming in c» نوشتهٔ thibaut meurisse، Kerry J Donovan (editor) و Hubert Henry Ward، منتشرشده توسط نشر Apress L. P. در سال 2023. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Embark on a journey into the world of embedded programming. This book introduces you to the 32bit PIC and will teach you how the main functions of C programming work and can be used with a PIC micro. My main aim in writing this book is to introduce you to the 32-bit micro and help you understand how to program them in the C programming language. I also want to show you that you can program them and that you can make a career as an embedded programmer. I hope that after reading this book, you will have developed your understanding of C and that you will have the confidence to go and develop your own programs. A one-stop reference for the would-be embedded programmer, you'll explore the electronics needed for a variety of programs as well as how to use different devices with the PIC. The book starts with downloading the environment and creating a simple project, one that uses different oscillators, Phase Lock Loop, and circuitry needed to create the different system clocks—an easy entry point to this exciting environment. You'll also review the MPLABX integrated development environment (IDE) and see how to program the 32Bit PIC, which can be adapted to different PICs. Throughout subsequent chapters, you’ll learn how to use a range of programs that use PIC modules such as the SPI, I2C, UART communication modules, the ADC module, the Capture, Compare, and Pulse Width Modulation module, and the RTCC, Real Time Clock and Calendar Module. What You'll Learn: Create a project in MPLABX Configure the different clock frequencies that are used in the 32bit PIC Build a variable delay subroutine to be used in a simple traffic lights program Use the MAX 7219 driver IC to control the 8by8 matrix display Program an I2C expander module to control the display on a LCD Prerequisites: As to any prerequisites you need before reading this book, there are none. I will assume you are a complete novice, and I will explain every step as you progress through the book. Every instruction will be analyzed to explain how the C instruction works and how it achieves what we want from the instructions. The only things you will definitely need to use this book are as follows. Who This Book Is For: Readers who want to try their hand at embedded programming, newcomers to programming the PIC 32, programmers who want to look into using MPLAB Harmony 3, and programmers who want to understand how C instructions work with respect to 32bit PIC. Also students who are studying for an engineering qualification. Table of Contents 5 About the Author 14 About the Technical Reviewer 15 The Aims and Objectives of the Book 16 Introduction 18 Chapter 1: Creating Our First C Program 29 What Is MPLAB X 29 Creating a Project in MPLAB X 30 The Initial Comments 39 The Speed of the Clock 41 Writing the Configuration Words 44 Our First Program 48 Setting the PORTS 50 Exercise 1-1 51 The Hexadecimal Number System 51 The First Program Listing 56 Analysis of Listing 1-1 58 Simulating the Program in MPLAB X 64 Solution to Exercise 1-1 72 Summary 72 Chapter 2: Header Files and Delays 74 What Are Header Files and Why We Use Them? 74 Creating a Header File 75 Using the Header File 79 Slowing the PIC Down 83 Creating a Delay 83 The Variable Delay Subroutine 88 What Is a Subroutine 88 The Analysis of the Delay Subroutine 89 Creating a 1ms Delay 93 Good Programming Practice 95 The Algorithm 95 The Flowchart 96 Our First Useful Program 97 The Algorithm 97 The Allocation List 99 The Flowchart for the Program 99 Creating the Project 100 Analysis of Listing 2-3 103 Downloading the Program to a Prototype Board 104 Extending the Program to the Crossroads Traffic Lights 107 The Algorithm 109 Analysis of Listing 2-4 114 Simulating the Program Within MPLAB X 115 Summary 118 Chapter 3: The Seven-Segment Display 119 Controlling a Seven-Segment Display 119 The Seven-Segment Display 119 Common Anode Seven-Segment Display 120 Common Cathode Seven-Segment Display 121 Controlling the Display with the PIC 123 The Seven-Segment Display Program 125 The Algorithm 125 The Flowchart 126 The Listing for the Seven-Segment Display Program 128 Analysis of Listing 3-1 130 Improving the Seven-Segment Display Program 132 The Problem with the Program 133 Arrays 133 Using Pointers 136 Analysis of Listing 3-2 137 The Improved Program 139 Exercise 3-1 144 Solution to Exercise 3-1 144 Summary 144 Chapter 4: The LCD 145 The 1602 LCD 145 Instruction or Command Mode 147 Data Mode 147 The Control Pins of the LCD 148 The LCD Header File for PORTE 149 Analysis of Listing 4-1 154 Analysis of Listing 4-2 175 Creating Your Own Symbols to Display on the LCD 178 The Pixel Maps 179 The 8-Bit Binary Values for the Four Special Characters 182 The Program “Pixel to Matrix” 184 The Special Character Program 186 The Program Listing for the Special Character Program 187 Analysis of Listing 4-3 192 Summary 197 Chapter 5: The Dot Matrix Display 198 The 8 by 8 Dot Matrix Board 198 The Single Dot Matrix Display 198 The Max7219 Driver IC 199 Writing to the Max7219 200 Analysis of Listing 5-1 208 Creating the Data for Each Row in the Two-Dimensional Array 209 Controlling Four 64-Bit Dot Matrix Boards 221 Analysis of Listing 5-3 250 Analysis of Listing 5-2 252 A Program to Scroll Text on the Matrix Display 258 Summary 275 Chapter 6: Communication 276 The 25LC256 EEPROM 281 What Is an EEPROM Device 281 Writing to the EEPROM 283 Reading from the EEPROM 285 The Connections of the EEPROM on the Explorer 16 Development Board 286 The Algorithm for the EEPROM Program 287 Analysis of Listing 6-1 292 The Setting of the CKE and CKP Bits 301 The Message “Ann Ward” 311 Using the Parallel Master Port 312 The Data for the PMMODE Control Register 313 The PMCON Control Register 314 The PMAEN Control Register 315 Analysis of Listing 6-2 320 Analysis of Listing 6-3 325 Summary 334 Chapter 7: The I2C Communication 335 The I2C Protocol 335 I2C Communication Protocol 335 Writing to the Slave 337 The Start Bit 337 The Address Bits and Control Bit in the First Byte 337 The Acknowledgment Bit 338 The Data Byte 338 The Stop Bit 338 Reading from the Slave 339 The NACK or Not Acknowledgment Bit 341 Analysis of the I2C Protocol Header File 345 The I2C Expander Module 354 The LCD2004 355 The Connections of the I2C Expander 356 Analysis of Listing 7-2 363 The Program to Use the I2C Expander to Control the LCD2004 378 Analysis of Listing 7-3 381 Summary 386 Chapter 8: Interrupts 388 Interrupts 388 The Fetch and Execute Cycle 390 The Program Counter or “PC” 390 Single Vectored Interrupts 391 Multivectored Interrupts 392 How Does the PIC Keep Track of Where It Must Go and Where It Must Get Back To? 392 The Stack and Its Main Use 393 The Sources of Interrupts in a 32-Bit PIC 395 Analysis of Listing 8-1 403 Using More Than One Interrupt Source with Single Vector Mode 414 Analysis of Listing 8-2 417 Interrupt Priority 420 Multivectored Interrupts with Priority 421 Analysis of Listing 8-3 424 Summary 427 Chapter 9: The Real-Time Clock 428 The External Crystal 32.768kHz Oscillator 429 The 24-Hour LCD Clock Program 429 Analysis of Listing 9-1 445 The TM1637 and the Four Seven-Segment Displays 459 The TM1637 Driver IC 460 Analysis of Listing 9-2 478 Summary 486 Chapter 10: The Real-Time Clock and the DS3231 488 The DS3231 RTC Module 488 The Order the DS3231 Expects the Data 499 The Program Algorithm 500 Displaying the Temperature 501 Binary Numbers 502 Adding Binary Numbers 505 Reading the Temperature from the TC72 506 Examples of the Two’s Complement Process 507 Using the UART and a Terminal Software 513 Using the Alarms of the DS3231 513 The UART 514 The UxMODE Control Register 515 The UxSTA Register 519 Using Tera Term 523 Connecting the Devices to the PIC32 528 Analysis of Listing 10-1 551 Summary 579 Chapter 11: The RTCC Module 581 The RTCC Module of the 32-Bit PIC 581 BCD (Binary-Coded Decimal) 587 Displaying the 32-Bit Value on the LCD 594 RTCC Module Program 594 Analysis of Listing 11-1 613 Understanding Instruction on Line 504 RTCALRM = 0x8403; 634 Summary 640 Chapter 12: The Real Analog World 641 The Real-World Signals 641 An Analog Signal 642 The Digital World 642 A Simple Voltmeter Program 643 The Algorithm of the Voltmeter Program 644 Analysis of Listing 12-1 647 The ADC Process 650 The Acquisition Time 650 The 4–20mA Transducer 662 Controlling Two Analog Inputs 663 Analysis of Listing 12-2 666 Summary 670 Chapter 13: The DHT11 Transducer 671 The DHT11 Humidity and Temperature Sensor 671 Communicating with the DHT11 672 The Use of a Pull-Up Resistor 677 The DHT11 Program Listing 677 Analysis of Listing 13-1 681 The Logical OR and AND Truth Tables 691 A Design Procedure 693 Know the Events You Want to Control 693 Analysis of Listing 13-2 700 Simulating the Program in MPLAB X 705 Summary 711 Chapter 14: Creating a Square Wave 712 Creating a Simple Square Wave 712 Using the Output Compare Module (OCMP) of the PIC32 714 Using the Logic Analyzer Within MPLAB X 719 Creating Some Musical Notes 725 Creating a PWM Square Wave with the OC1MP Module 729 The Average of a Square Wave 729 Analysis of Listing 14-4 738 Varying the Brightness of a Lamp 741 Analysis of Listing 14-5 745 Summary 749 Appendix 750 Data Types and Memory 750 The Program Memory Area 750 The Data RAM 751 The Data EEPROM 751 Variables 751 Appendix 1: Data Types 752 Appendix 2: Some Useful Definitions 753 Appendix 3: Mathematical and Logic Operators 754 Appendix 4: Keywords 756 Appendix 5: Numbering Systems Within Microprocessor-Based Systems 757 Introduction 757 Binary Numbers 757 Converting Decimal to Binary 758 Example 1 758 Converting from Binary to Decimal 759 Example 2 760 Exercise 1 760 Adding and Subtracting Binary Numbers 761 Exercise 2 761 Worked Example 761 Subtracting Binary Numbers 762 Exercise 3 762 Worked Example 762 The Hexadecimal Number System 763 Exercise 4 765 Worked example 765 Appendix 6: The ASCII Character Set 766 Appendix 7: The LCD Instruction Set 768 Index 770 Capture.PNG -1 Capture.PNG 1
دانلود کتاب INTRODUCTORY PROGRAMS WITH THE 32BIT PIC MICROCONTROLLER : a line-by line code analysis... and reference guide for embedded programming in c