Programming 32-bit Microcontrollers in C: Exploring the PIC32

Paperback (Print)
Rent
Rent from BN.com
$24.72
(Save 66%)
Est. Return Date: 10/28/2014
Used and New from Other Sellers
Used and New from Other Sellers
from $42.19
Usually ships in 1-2 business days
(Save 42%)
Other sellers (Paperback)
  • All (18) from $42.19   
  • New (12) from $43.21   
  • Used (6) from $42.19   
Close
Sort by
Page 1 of 2
Showing 1 – 10 of 18 (2 pages)
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$42.19
Seller since 2009

Feedback rating:

(10249)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

Good
Used - Very Good Book. Shipped from US within 4 to 14 business days. Established seller since 2000

Ships from: Secaucus, NJ

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$43.21
Seller since 2008

Feedback rating:

(3032)

Condition: New
All orders ship SAME or NEXT business day. Expedited shipments will be received in 1-5 business days within the United States. We proudly ship to APO/FPO addresses. 100% ... Satisfaction Guaranteed! Read more Show Less

Ships from: Grandview Heights, OH

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$46.99
Seller since 2014

Feedback rating:

(868)

Condition: Good
This Book has Some Wrinkled Pages. This Book has Some Staining. May have minimal notes/highlighting, minimal wear/tear. Please contact us if you have any Questions.

Ships from: Downingtown, PA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$46.99
Seller since 2014

Feedback rating:

(868)

Condition: Acceptable
With CD! Moderate Amount of Wrinkled Pages. Staining. May have some notes/highlighting, slightly worn covers, general wear/tear. Please contact us if you have any Questions.

Ships from: Downingtown, PA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$46.99
Seller since 2014

Feedback rating:

(868)

Condition: Very Good
Excellent Condition. No wear/tear. Additional Supplements May not be Included unless previously specified. Please contact us if you have any Questions.

Ships from: Downingtown, PA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$46.99
Seller since 2014

Feedback rating:

(868)

Condition: Like New
Clean and crisp. No wear and tear. Additional Supplements May not be Included unless previously specified. Please contact us if you have any Questions.

Ships from: Downingtown, PA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$50.49
Seller since 2008

Feedback rating:

(17560)

Condition: New
Brand New, Perfect Condition, Please allow 4-14 business days for delivery. 100% Money Back Guarantee, Over 1,000,000 customers served.

Ships from: Westminster, MD

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
$50.71
STO
Seller since 2010

Feedback rating:

(399)

Condition: New
US Edition Book In Mint condition. Shipping with Trackable Method.

Ships from: Houston, TX

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$56.45
Seller since 2008

Feedback rating:

(4464)

Condition: New
New Book. Shipped from UK within 4 to 14 business days. Established seller since 2000.

Ships from: Horcott Rd, Fairford, United Kingdom

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$56.63
Seller since 2009

Feedback rating:

(10249)

Condition: New
New Book. Shipped from US within 4 to 14 business days. Established seller since 2000

Ships from: Secaucus, NJ

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 2
Showing 1 – 10 of 18 (2 pages)
Close
Sort by

Overview

*Just months after the introduction of the new generation of 32-bit PIC microcontrollers, a Microchip insider and acclaimed author takes you by hand at the exploration of the PIC32

• Companion website includes source code in C and the Microchip MPLAB C32 compiler

• Includes handy checklists to help readers perform the most common programming and debugging tasks

The new 32-bit microcontrollers bring the promise of more speed and more performance while offering an unprecedented level of compatibility with existing 8 and 16-bit PIC microcontrollers. In sixteen engaging chapters, using a parallel track to his previous title dedicated to 16-bit programming, the author puts all these claims to test while offering a gradual introduction to the development and debugging of embedded control applications in C.
Author Lucio Di Jasio, a PIC and embedded control expert, offers unique insight into the new 32-bit architecture while developing a number of projects of growing complexity.
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 using the new PIC32 features and peripheral set.

You will learn about:
• basic timing and I/O operation
• debugging methods with the MPLAB SIM *simulator and ICD tools
• multitasking using the PIC32 interrupts
• all the new hardware peripherals
• how to control LCD displays
• experimenting with the Explorer16 board and *the PIC32 Starter Kit
• accessing mass-storage media
• generating audio and video signals
• and more!

Read More Show Less

Product Details

  • ISBN-13: 9780750687096
  • Publisher: Elsevier Science
  • Publication date: 4/17/2008
  • Series: Embedded Technology Series
  • Pages: 552
  • Sales rank: 1,315,029
  • Product dimensions: 7.40 (w) x 9.10 (h) x 1.60 (d)

Meet the Author

Lucio Di Jasio is now Sales Manager in Europe for Microchip Inc. He was previously Application Segments Manager at Microchip in Chandler AZ. He has been intimately involved in the development of Microchip PIC products for over 10 years and is a well known writer and expert on the use of PIC products both via his Newnes books and his work at events such as the Microchip Masters.

Read More Show Less

Read an Excerpt

Programming 32-bit Microcontrollers in C

Exploring the PIC32
By Lucio Jasio

Newnes

Copyright © 2008 Elsevier Inc.
All right reserved.

ISBN: 978-0-08-056010-6


Chapter One

DAY 1

The Adventure Begins

The Plan

This will be our first experience with the PIC32 32-bit microcontroller and, for some of you, the first project with the MPLAB® IDE Integrated Development Environment and the MPLAB C32 language suite. Even if you have never heard of the C language, you might have heard of the famous "Hello World!" programming example. If not, let me tell you about it.

Since the very first book on the C language, written by Kernighan and Ritchie several decades ago, every decent C language book has featured an example program containing a single statement to display the words "Hello World" on the computer screen. Hundreds, if not thousands, of books have respected this tradition, and I don't want my books to be the exception. However, our example will be just a little different. Let's be realistic—we are talking about programming microcontrollers because we want to design embedded-control applications. Though the availability of a monitor screen is a perfectly safe assumption for any personal computer or workstation, this is definitely not the case in the embedded-control world. For our first embedded application we'd better stick to a more basic type of output: a digital I/O pin. In a later and more advanced chapter, we will be able to interface to an LCD display and/or a terminal connected to a serial port. But by then we will have better things to do than writing "Hello World!"

Preparation

Whether you are planning a small outdoor trip or a major expedition to the Arctic, you'd better make sure you have the right equipment with you. Our exploration of the PIC32 architecture is definitely not going to be a matter of life or death, but you will appreciate the convenience of following the few simple steps outlined here before getting your foot out the door ... ahem, I mean before starting to type the first few lines of code.

So, let's start by verifying that we have all the necessary pieces of equipment ready and installed (from the attached CD-ROM and/or the latest version available for download from Microchip's PIC32 Web site at microchip.com/PIC32). You will need the following:

• MPLAB IDE, free Integrated Development Environment (v8.xx or later)

• MPLAB SIM, free software simulator (included in MPLAB)

• MPLAB C32, C compiler (free Student Edition)

Now let's use the New Project Setup checklist to create a new project with the MPLAB IDE. From the Project menu, select the Project Wizard. This will bring up a short but useful sequence of little dialog boxes that will guide us through the few steps required to create a new project in an orderly and clean way:

1. The first dialog box will ask you to choose a specific device model. Select the PIC32MX360F512L device and click Next. Although we will use only the simulator, and for the purpose of this project we could use pretty much any PIC32 model, we will stick to this particular part number throughout our exploration.

2. In the second dialog box, select the PIC32 C-Compiler Tool Suite and click Next. Many other tool suites are available for all the other PIC© architectures, and at least one other tool suite is already available for development on the PIC32 in assembly; don't mix them up!

3. In the third dialog box, you are asked to assign a name to the new project file. Instead click the Browse button and create a new folder. Name the new folder Hello, and inside it create the project file Hello World, then click Next.

4. In the fourth dialog box, simply click Next to proceed to the following dialog box since there is no need to copy any source files from any previous projects or directories.

5. Click Finish to complete the project setup.

Since this is our first time, let's continue with the following additional steps:

6. Open a new editor window by selecting File | New, typing the Ctrl + N keyboard shortcut or by clicking the corresponding [??] (New File) button in the MPLAB standard toolbar.

7. Type the following three comment lines:

/* **Hello Embedded World! */

8. Select File | Save As to save the file as Hello.c.

9. Now right-click with your mouse on the editor window to bring up the editor's context menu and select the Add To Project item. This will tell MPLAB that the newly created file is an integral part of the project.

10. Select Project | Save Project to save the project.

Once you are finished, your project window should look like the one in Figure 1.1. If you cannot see the project window, select View | Project. A small check mark should appear next to the item in the View menu. Also make sure that the Files tab is selected. We will review the use of the other tab (Symbols) in a later chapter.

Depending on your personal preferences, you might now want to "dock" this window to assign it a specific place on your workspace rather than keeping it floating. You can do so by right-clicking with your mouse on the title bar of the small window to access the context menu and selecting the Dockable option. You can then drag it to the desired edge of the screen, where it will stick and split the available space with the editor.

The Adventure Begins

It is time to start writing some code. I can sense your trepidation, especially if you have never written any C code for an embedded-control application before. Our first line of code is:

#include <p32xxxx.h>

This is not yet a proper C statement but an instruction for the preprocessor (which feeds the compiler) with the request to include the content of a device-specific file before proceeding any further. The pic32xxxx.h file, in its turn, contains more #include instructions designed so that the file relative to the device currently selected in the project is included. That file in our case is p32mx360f512l.h. We could have used its name directly, but we chose not to in order to make the code more independent and hopefully easier to port, in the future, to new projects using different models.

If you decide to further inspect the contents of the p32mx360f512l.h file (it is a simple text file that you can open with the MPLAB editor), you will see that it contains an incredibly long list of definitions for all the names of the internal special-function registers (often referred to in the documentation as the SFRs) of the chosen PIC32 model. If the include file is accurate, those names reflect exactly those being used in the device datasheet and the PIC32 reference manual.

Here is a segment of the p32mx360f512l.h file in which the special-function register that controls the watchdog module (WDTCON) and each of its individual bits are assigned their conventional names:

... extern volatile unsigned int WDTCON__attribute__ ((section("sfrs"))); typedef union { struct { unsigned WDTCLR:1; unsigned WDTWEN:1; unsigned SWDTPS0:1; unsigned SWDTPS1:1; unsigned SWDTPS2:1; unsigned SWDTPS3:1; unsigned SWDTPS4:1; unsigned :7; unsigned FRZ:1; unsigned ON:1; }; ...

Back to our Hello.c source file; let's add a couple more lines that will introduce you to the main() function:

main() { }

What we have now is already a complete, although still empty and pretty useless, C language program. In between those two curly brackets is where we will soon put the first few instructions of our embedded-control application.

Independently of this function position in the file, whether in the first lines on top or the last few lines in a million-lines file, the main() function is the place where the microcontroller will go first at power-up or after each subsequent reset. This is actually an oversimplification. After a reset or at power-up, but before entering the main() function, the microcontroller will execute a short initialization code segment automatically inserted by the MPLAB C32 linker. This is known as the Startup code or crt0 code (or simply c0 in the traditional C language literature). The Startup code will perform basic housekeeping chores, including the all important initialization of the stack, among many other things.

Our mission is to activate for the first time one or more of the output pins of the PIC32. For historical reasons, and to maintain the greatest compatibility possible with the many previous generations of PIC microcontrollers, the input/output (I/O) pins of the PIC32 are grouped in modules or ports, each comprising up to 16 pins, named in alphabetical order from A to H. We will start logically from the first group known as PortA. Each port has several special-function registers assigned to control its operations; the main one, and the easiest to use, carries traditionally the same name as the module (PORTA).

Notice how, to distinguish the control register name from the module name in the following, we will use a different notation for the two: PORTA (all uppercase) will be used to indicate one of the control registers; PortA will refer to the entire peripheral module.

According to the PIC32 datasheet, assigning a value of 1 to a bit in the PORTA register turns the corresponding output pin to a logic high level (3.3V). Vice versa, assigning a value of 0 to the same bit will produce a logic level low on the output pin (0V).

Assignments are easy in C language—we can insert a first assignment statement in our project as in the following example:

#include <p32xxxx.h>

main() { PORTA = 0xff; }

First, notice how statements in C must be terminated with a semicolon. Then notice how they resemble mathematical equations—they are not!

An assignment statement has a right side, which is computed first. A resulting value is obtained (in this case it was simply a constant expressed in hexadecimal notation) and it is then transferred to the left side, which acts as a receiving container. In this case it was the special-function PORTA register of the microcontroller.

Compiling and Linking

Now that we have completed the main() and only function of our first C program, how do we transform the source into a binary executable?

Using the MPLAB Integrated Development Environment (IDE), it's very easy! It's a matter of a single click of your mouse in an operation called a Project Build. The sequence of events is actually pretty long and complex, but it is mainly composed of two steps:

1. Compiling. The MPLAB C32 compiler is invoked and an object code file (.o) is generated. This file is not yet a complete executable. Though most of the code generation is complete, all the addresses of functions and variables are still undefined. In fact this is also called a relocatable code object. If there are multiple source files, this step is repeated for each one of them.

2. Linking. The linker is invoked and a proper position in the memory space is found for each function and each variable. Also, any number of precompiler object code files and standard library functions may be added at this time, as required. Among the several output files produced by the linker is the actual binary executable file (.hex).

All this is performed in a very rapid sequence as soon as you ask MPLAB to build your project. Each group of files, as presented in the project window (refer back to Figure 1.1), will be used during the project build to assist in the compiling or linking phase:

• Every source code (.c) file in the Source Files list will be compiled to produce relocatable object files.

• Each additional object file in the Object Files list will then be linked together with the previous object files.

• The Library Files list will also be used during the linking process to search for and extract library modules that contain functions, if any have been used in the project.

• Finally, the Linker Script section might contain an additional file that can be used to provide additional instructions to the linker to change the order and priority of each data and code section as they are assembled in the final binary executable file. The MPLAB C32 tool suite offers a default linker script mechanism that is sufficient for most general applications and certainly for all the applications we will review in this book. As a consequence, for the rest of this book we will safely leave this section of the project window empty, accepting the default setting provided.

The last two sections of the project window are treated differently:

• The Header Files section is designed to contain the names of the include files (.h) used. However, they don't get processed directly by the compiler. They are listed here only to document the project dependencies and for your convenience; if you double-click them they will open immediately in the editor window.

• The Other Files section is designed to contain the names of any additional file, not included in any of the previous categories but used in the project. Once more this section serves a documentation purpose more than anything else.

(Continues...)



Excerpted from Programming 32-bit Microcontrollers in C by Lucio Jasio Copyright © 2008 by Elsevier Inc.. Excerpted by permission of Newnes. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More Show Less

Table of Contents

Day 1 And the adventure begins
Day 2 Walking in circles
Day 3 Message in a Bottle
Day 4 NUMB3RS
Day 5 Interrupts
Day 6 Memory
Part 2 Experimenting
Day 7 Running
Day 8 Communication
Day 9 Links
Day 10 Glass = Bliss
Day 11 It’s an analog world
Part 3 Expansion
Day 12 Capturing User Inputs
Day 13 UTube
Day 14 Mass Storage
Day 15 File I/O
Day 16 Musica Maestro!

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)