Intermediate C Programming for the PIC Microcontroller: Simplifying Embedded Programming
after payment (24/7)
(for all gadgets)
(including for Apple and Android)
This book looks at some useful aspects of the PIC microcontroller. Itexplains how to write programs in C so that you can use the PIC micro tocontrol a variety of electronics and DC motors. After reading this book, youwill be well on your way to becoming an embedded programmer using theC programming language.The Aims and Objectives of This BookThe main aim of this book is to introduce you to some useful applicationsof programming PIC micros such as• Creating header files• Controlling seven-segment displays• Using an LCD display with two lines of 16 characters• Pulse width modulation• Using driver ICs such as the ULN2004A• Controlling DC motors, including stepper motors andservo motors• Using every aspect of the Capture, Compare and PWM,CCP module in the PIC• Using interrupts• Writing to the EEPROM
Another useful piece of software is a suitable ECAD (electroniccomputer-aided design) software program that supports 8-bit micros.The ECAD software I use is PROTEUS. However, it is not free, so as well asshowing you how to simulate the programs in PROTEUS, I will show youhow to use a suitable prototype board to run the programs in a practicalsituation.If you want to go down the practical route, you will need to purchase aprogramming tool and a prototype board.The tools I use are either the ICD3 can (Microchip has now movedonto the ICD4 can) or the PICkit3 programmer to download the programsfrom MPLABX to the PIC.The prototype board I use is the picdem2 plus DEMO BOARD anda prototype board from Matrix Multimedia (although Matrix no longerproduces the more versatile board that I use).This book was written based around using MPLABX V5.25.However, the principles of how to create projects and write programsare transferable to earlier and later versions of MPLABX. There may besome slight differences in the details, but they shouldn't cause too manyproblems.The PIC that this book is based around is the PIC18F4525. This is avery versatile 8-bit micro that comes in a 40-pin dual-inline package. Aslong as the PIC you want to use has the same firmware modules, then theprograms in the book can easily be used on other PIC micros with someminor modifications. However, you should always refer to the data sheetfor the particular PIC you use because some of the SFRs (special functionregisters) may differ. For example, the PIC18F4525 uses the ADCON0,ADCON1, and ADCON2 SRFs to control the ADC module but the 16F88uses the ANSEL, ADCON0, and ADCON1 registers.Throughout the book, I include program listings and I go through ananalysis of any new instructions that the listings introduce. With respect tothe first listing, I will assume that all of the instructions are new to you, thereader.Before we move into the book for real, I think it will be useful to you ifI explained a bit about what MPLABX is. It is an industrial IDE created byMicrochip. The term IDE stands for integrated development environment.It is actually a lot of programs collected together to create a programmingenvironment:• There is an editor, which is slightly more than a simpletext editor. However, in my early days, I used to writemy programs in Notepad.• There is also a compiler program that converts yourprogram instructions from C to the machine code thatall microprocessor-based systems use. In the very earlydays of programming, the programmers used to writein this machine code. This was a bit before my time,although in my early days, I wrote all my programsin assembler. Assembler is the closet language to theactual machine code that all micros use.• There is also a linker program that will bring togetherany include files that we wish to use in our projects.• As well as these programs, there are a range ofprograms that we can use to help debug our programsor simply simulate them.So this IDE is a very large collection of programs that make our job ofwriting code much more efficient. Yet it’s free; well, I use the free version,which is not as efficient as the paid version but it is more than goodenough for us.I therefore hope that you not only learn how to program the PIC microbut you also enjoy going through my book and that you produce someuseful projects along the way.
Data sheet
- Language
- English