|
microcontroller 8051, PIC microcontroller and advanced microcontrollers
A complete 5 module tutorial(lecture series) to cover the entire 8051, PIC and advance microcontrollers for those who wants to have the complete knowledge about microcontrollers.
Lecture 45 : PIC Serial Communication using Serial Peripheral Interface (SPI)
Lecture 44 : Blinking LED with PIC16F877A
|
Lecture 43 : Interfacing PIC16F877 Microcontroller with an LCD
Aim
To interface LCD (Displaytech 162A) with PIC16F877microcontroller and to display "IITK" in the Liquid Crystal Display (LCD).
Components/Softwares
- MPLAB IDE (PIC microcontrollers simulator)
- PIC BURNER 3 with software to load the code
- LCD (Displaytech 162A)
- Computer System with Windows operating system and RS 232 cable
- PIC16F877 Microcontroller
- +5V D.C Power Supply
- Resistors - 10K Ω-1,50Ω-1
- Capacitors - 27 µ F-2
- Potentiometers - 10K Ω -1
- 20MHz Crystal oscillator
- SPST switches -1
Fig 43.1 A view of the PIC programmer connected to the PC serial Port (COM1)
Procedure
- Write the assembly code in MPLAB IDE simulator , compile it and check for errors
- Once the code was error free, run it and check the output in the simulator.
- After checking the code in the simulator, load the code (in .HEX format) into PIC16F877 microcontroller using PIC BURNER3.
- Make connections as shown in the circuit diagram.
- Switch on the power supply and observe "IITK" displayed in the LCD.
Assembly Code
Circuit Diagram
Fig 43.2 Circuit Diagram
Fig 43.3 Circuit assembly on breadboard
Liquid Crystal Display (LCD-Displaytech 162A )LCD Displaytech 162A consists of a LCD panel, a controller IC (KS0070B) and a back light LED. The LCD module consists of total 16 pins in which, 2 are for power supply, 2 pins for Backlight LED, one pin for contrast adjustment, 3 pins are for control signals and 8 pins are data pins. In order to display any data, we need to do certain initiations. The following are the main three steps in displaying any data in the LCD display.- Initializing LCD by sequence of instructions
- Executing commands depending on our settings in the LCD
- Writing data into the DRAM locations of LCD in the Standard Character Pattern of LCD
MPLABIDEMPLABIDE is a free software which can be downloaded from the website www.microchip.com
Working with MPLABIDE :
MPLABIDE is a simulator for PIC microcontrollers to write and edit the code in assembly language, compile it and also to run the code. Output can be verified using simulator.
Steps to Use MPLABIDE
- After Installing the software MPLABIDEv7.2,open MPLABIDE.
- To built a new project, open
Project Project Wizard
Project wizard New
Device 16F877
Location (Ex:C:\ProgramFiles\Microchip\MPASM Suite\MPASMWIN.EXE) Next
<Project name>&<Project Directory> Next
(Add file "f877tmpo.asm" which was located in programfiles microchip MPASMSuite Template Object)
(Add file "16f877.lkr" which was located in programfiles microchip MPASMSuite LKR)
Next Finish
To have more clear refer to MPLABIDE help files. - After building the project open the editor f877tmpo.asm and write the assembly code
- After writing the assembly code in the editor, build the project by clicking on the following option
Project Build all - Check for the errors in the output window
View Output - Once the error free code was made, simulate the code by following option
Debugger Select Tool MPLAB SIM - Simulator options are
- Step into - Each time only one instruction will be executed (Single stepping mode)
- Run - To run the whole code at once.
- Animate - to animate the executing the code
- Additional things:
- To view DRAM, program memory, SFRs, and External memory use the option VIEW
- To set break points in the code (where simulation stops at that point). Debugger Breakpoints
- To stop the simulation
Debugger Halt
- Connect the PIC BURNER3 through RS232 Port to computer system with windows98 as operating system.
- Execute the file "icprog" which was in the software that comes with PIC BURNER3.
- Set the device as PIC16F877
- Switch on the power supply of PIC BURNER3
- Settings Hardware { JDM Programmer,Com1,Direct I/O}
- Settings Hardware check 1. on clicking "Enable Data out", Data in must be clicked automatically
2. on clicking Enable MCLR, red LED on the PICBURNER3 must glow - Settings Options Confirmation [ Erasing the devise,Code Protecting the Devise]
- Settings Options MISC Process Priority Normal
- Settings Options Programming Verify After Programming.
- Remaining options keep them at default settings. [Refer Manual of PICBURNER3 for detail]
- Now insert the 16F877 microcontroller into the slot provided on the PICBURNER3 as the direction specified in the manual of PICBURNER3.
- load the .hex file
File open file - Command Erase All
- Command Blank Check
Then there should be a notice on the window that "Device is Blank " - Command Program All
- Command Blank Check
Then there should be a notice on the window that "Device is not blank at address 0x0000H". - Close the window, remove the IC from the PIC BURNER3 and switch off the power supply for PIC BURNER3.
Subscribe to:
Posts (Atom)