How to Interface LCD (in 8 bit) with PIC24 16bit Microcontroller Code + Proteus Simulation



This post is all about how to interface 16x2 LCD with microcontroller in 8bits mode. In this particular example I will interface LCD with PIC24 (16bit microcontroller). You may download Proteus Simulation and code from the links given at the bottom of this post.

            I am using MPLAB X IDE and C30 Compiler for 16bit microcontrollers. I supposed that you know following.

·         How to blink an LED (if not then I suggest you to read this (link) first before continuing this post).
·         How to generate a delay without timers or with timers (if not then I suggest you to read this (link) first        before continuing this post).

Proteus Simulation:

Proteus Simulation

            In the above circuit we have an LCD connected with PORT B remember this is 16bit port I am using 10MHz crystal and my Cycle frequency is 5MHz

Code:

In the figure below we have a main function in which we initialize LCD and a while loop to display string on LCD and update LCD after every 1.3 seconds.

Main Function


In the figure below I defined the pins and port for LCD.




In Initialize_LCD() I made Enable and RS(Register Select) pins and portB  as output by setting their Tristate registers. And then I write some commands to LCD which are necessary for initialization as describes in datasheet.



In this figure I have ClearScreen_LCD() which is used so many times when you have a project that’s why it is separated from other commands. And we have Toggle_Enable_Pin_LCD() which should be called to latch data onto LCD every time you write o LCD data bus.



In the figure below I have WriteCmd_LCD(Parameter) which is used for writing command to LCD Masking PORTB is important as we have 16bits controller. Parameter is 8bit command which we want to write on LCD. WriteData_LCD(Parameter) is used to send data which is displayed on LCD.



Hope that this will help you!!! For any suggestions or help you are free to comment.


Reading Suggestions:


Downloads:

You can download Code and Proteus Simulation
 Click here



©IbrahimLabs.blogspot.com

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