Tutorial for Configuration Bits setting PIC32 (32 Bit PIC Microcontroller).

This post will provide a tutorial of how to set configuration bits for PIC32 series. As we have 32bit microcontroller from Microchip. All PIC microcontroller series have slightly changed configuration bits setting. I will explore the easiest way to set the configuration bits for PIC32 series in this tutorial.

You may download code example or configuration bits setting from the download section at the bottom of this page. I am using MPLAB X IDE, XC32 Compiler. This code is written in C Language and will work on all PIC32 (32bit microcontroller by Microchip) by slightly changing the code according to their features.

In this post I will not go in details of every single configuration bit. I supposed that you know following if not then please read them before proceeding further in this post.

Step 1:

As I am using PIC32MX460F256L in this particular example. So the first step is to find a place where you can easily find the relevant configuration bits for your PIC microcontroller. Here you go into the main folder in which you installed the XC32 compiler. In my case it is “C:\Program Files (x86)\Microchip\xc32\v1.21\docs” Now here you will find a document for setting configuration bits as “PIC32ConfigSet.pdf” as shown in figure 1 below.

Figure 1.

Step 2:

Now go to bookmarks in PDF viewer and find your PIC32 microcontroller in the list and click on it you will get to a table where every single bit that is present in your microcontroller is defined as shown in following figure 2.

Figure 2. Bookmark.

The table is somewhat like that as shown in the following figure 3.

Figure 3. Table of Configuration Bits.

Step 3:

          Now to set the configuration bits in this PIC32 controller you have to define them above your main function in your main code file with starting as “#pragma config” after this you have to write the configuration bits setting as in table for example for frequency PLL input divider of 2. I have “#pragma config FPLLIDIV = DIV_2 ”.

“I highly recommend that if you are beginner with microcontroller you must first read the datasheet about every single configuration bit you are going to define in the code. Just read it one by one by searching them in the datasheet don’t go with full datasheet reading at first. It will consume a lot of time and effort to read about 200 above pages of datasheet. Let me tell you what I do is; I just go through the basic recommended circuitry and configurations bits setting to program microcontroller for the first time. And for the first time I must run LED blinking code for every new microcontroller. Which I think is a good approach to get started with it.”

Step 4:

Just like that I define them one by one. I only define the basic starting configuration bits rest of them was skipped because this application don’t need them. Like code protection, fail safe monitoring and clock switch over etc. So in this particular example I have an 8MHz high speed crystal connected externally. With the PLL input division of two and PLL enables my PIC32 is running at 80MHz speed. So system speed is 80MHz and peripheral Clock is also 80MHz because I div it by 1. Don’t over clock your PIC32. As it is not a safe thing to do with embedded systems regarding reliability of it. In the following figure 4. I have all the configuration bits setting done. And in the main function I just I just toggle an LED which is connected to RB0 in my custom made PIC32 IO board.

Figure 4. Main C file.

In the following figure 5. An animation is showing the toggling of an LED.

Figure 5. Animation of LED toggling.


You can download Code (MPLAB X and XC32 compiler). Click here

Reading Suggestions:

·         Over Voltage Protection
·         AC Voltmeter RMS + Peak voltage 

For all topics Click here:

That’s all for this post hope you will learn please comment if you have any questions for upcoming posts please subscribe or follow.

All the text and graphics contained on this blog belongs to owner except otherwise mentioned. Other parties' trademarks and service marks that may be referred to herein are the property of their respective owners. Reproducing or distributing text and graphics on your own site is strictly not allowed without proper linking to original content and before publishing that you should ask for permission. 

© Copyright 2013 IbrahimLabs. All rights reserved.

Popular posts from this blog

Defining code regions in MPLAB X IDE

Digital AC voltmeter Schematic + Code + Proteus Simulation

Graphical LCD interfacing with PIC16F877 Code + Schematic + Proteus Simulation