Posts

Showing posts from 2014

Defining code regions in MPLAB X IDE

Image
In this post I would like to share "How to define code in regions using MPLAB X". This post has very much importance in good programming practice that's why I want to share it with you guys. I personally like this feature in MPLAB X remember this feature is only available in MPLAB X. With this feature you can define code in regions likewise you may have done in Microsoft Visual Studio. When you define certain code in regions you may easily handle the code you are interesting in. For example if you define certain interrupt setting registers code in one region and frequency setting code in other regions.

    Following figure 1 shows how an organized code looks like. Which I do in coding as general practice. In this code I organized all Debug LEDs, Spare Pins, Input buttons etc in separate regions. So whenever I want to change certain regions I quickly click on "+"  sign and made changes without looking at other regions code.


     In the following figure 2. …

Graphical LCD interfacing with PIC16F877 Code + Schematic + Proteus Simulation

Image
This tutorial is all about "How to interface Graphical LCD with PIC16F877". You may download code, schematic and Proteus simulation from the download section at the bottom of this page. 
     From this point I assumed that you know following (if not then read them before proceeding any further in this post).
How to use Mplab X IDE (Click Here).How to set Configuration bits in code (Click Here).How to blink an LED (Click Here).Proteus Simulation:
     In the following figure 1. We have proteus simulation in which I am using graphical LCD 128x64 with PIC16F877. This LCD is similar to JHD12864E (datasheet) with only addition of two pins those for LCD backlight. I have tested this code on real graphical LCD it is working.

    In the following figure 2. PortD is connected to DATA and ADDRESS bus of graphical LCD. whereas PortC higher bits are connected to LCD control signals. As you have seen the Reset (RST) pin is active low.A variable resister is for LCD contrast. MCLR pin is …

LCD interfacing with PIC16F877 Code and Simulation

Image
In this tutorial you will find Proteus simulation and Code of  "How to interface 16x2 LCD with PIC16F877 using MPLAB X IDE and XC8 compiler". You may download code, schematic and Proteus simulation from download section at the bottom of this page.
In this post I assumed that you must know following if not then please read them before proceeding any further in this post:
How to use MPLAB X IDE (Click Here).How to set Configuration bits in code (Click Here).How to Blink an LED (Click Here).
Proteus Simulation:
In figure 1. I have used PIC16F877 with PortB connected to an LCD as data and address bus whereas Register Select (RS) and Enable (E) pins are connected to Pins RC0 and RC1 respectively. Whereas MCLR is connected to 5VDC which means Controller is in Normal Operating mode (see datasheet for further details). I have set Crystal frequency 10MHz.

Code:
In the following figure 2. We have a main function in which we initialize LCD and a while loop to display strings on LC…

LED Blinking PIC16F877 Code + Proteus Simulation using xc8

Image
This post is all about how to blink an LED using PIC16F877 an 8 bit microcontroller from microchip. This is very basic tutorial for beginners. Code example is provided in download link below.
In this post I assumed that you must know following if not then please read them before proceeding further:
1.How to use MPLAB X IDE (Click here). 2.How to set Configuration bits in code (Click here).
You may download code, schematic and Proteus simulation from the download section at the bottom of this page. I am using MPLAB X IDE, XC8 Compiler.
Proteus Simulation:
I used PIC16F877 with PIN RB0 connected to an LED. MCLR is connected to 5VDC which means Controller is in Normal Operating mode (see datasheet for further details). Proteus simulation shows that LED is toggling after one second as I am using building delay functions I have set Crystal frequency 10MHz. The circuit is shown in figure 1.

Code:
This is the main code file showing the configuration bits area at the top and the main function in w…

How to set Configuration bits in Code PIC16F877.

Image
This post will provide a tutorial of how to set configuration bits in code for PIC16F877 an 8 bit microcontroller from microchip. Configuration bits are special features registers in CPU described in section “14 named Special features of the CPU” in datasheet of PIC16F877. This method also works for all PICs. Code is written in C language and I used the latest compiler XC8 with MPLABX IDE.
In this post I assumed that you must know following if not then please read them before proceeding further "How to use MPLAB X IDE".
You may download code, schematic and Proteus simulation from the download section at the bottom of this page. I am using MPLAB X IDE, XC8 Compiler.
Setting configuration bits allows you to start microcontroller from very basic level. So here is a shortcut. But you must know what these register means by reading the section 14 of datasheet. When you done with the code use following to set configuration bits easily. Go to windows->PIC memory Views->Configur…