Sie sind auf Seite 1von 3

Articles

Projects

Forum

Site Tools

Search

Feedback

MPASM Tutorial - Liquid Crystal Display (LCD)


Written by
Picem

Published on 21 April
2009

Hits:

10972
Tweet

Like

16x2 Blue
HD44780 LCD
www.411techsystems.com
High contrast, white LED
backlight No min order. Ships
fast from USA

Although single wire serial data communication with your PC is relatively hassle free (especially if coupled with a
PICKit 2), sometimes a 'stand alone' solution is required. This is where the Liquid Crystal Display (LCD) comes in very
handy.
There are a number of reasons why I prefer to use LCD's over segment/matrix displays, a lot of them are straight
forward; such as, far less wires, no need to continually 'refresh' display data and much more displayed information
in less area. As mentioned, there is no need to continually refresh the screen information as most generic "Character
LCD's" have an on-board controller (HD44780) that looks after all of that. You simply send a character to a
row/column position, the on-board controller will keep it visible in that location for as long as there is power or you
choose to change that information.
Consider the wiring diagram (note that the power supply has not been included for simplicity);

FORUM ACTIVITY
Teensy 3.0 - hop
Sunday, 01 December
2013 02:15 [0 replies]
Can man affect
gravity? - hop
Sunday, 01 December
2013 01:58 [6 replies]

converted by Web2PDFConvert.com

We would love
opinions on our new
embedded platfor... quickstack Thursday, 28
November 2013 22:34
[0 replies]
Good value for filter
capacitors? - baldor
Thursday, 28 November
2013 19:01 [4 replies]
An Interesting
Reference: Process
Control Solution... jon chandler Wednesday, 27
November 2013 17:58 [0
replies]
Simple (hopefully)
circuit question alexqw Monday, 25
November 2013 13:55
[2 replies]
A PIC24 Dev Board
from Microchip w4gns Monday, 25
November 2013 03:58 [16
replies]

RECENT ARTICLES
A No-Voltage-Drop
Bridge Rectifier

The 4.7K potentiometer can be any value upto 10K. You need to adjust it up/down to set the contrast of the LCD. Full
contrast will lead to black blocks across the screen, while no contrast will make the screen look as if nothing is on it
at all. I find setting up the LCD without the data pins (just power and ground) is a good way to set the contrast - as
the on-board controller will fill the first row with rectangles - allowing you to set the contrast correctly (without the
chance of trying to set it with a clear screen!)
Notice the data pins are connected to RB4:RB7. If you use a different port, then simply wire up the LCD in a similar
fashion, and declare the appropriate PORT.Pins for the new connections. (code below).
And of course, the code. I'm not going to break down the code overall much, it probably better if you simply copy &
paste it into a MPLAB project and simulate it. Step through the code and read the comments - there's quite a few
handy little techniques throughout such as defining the PORT.PIN at the start of the program so you only have to
change that information for the rest to follow suit);
Assem bly LCD Tutorial (PIC Microcontroller)

LIST p=16F628A ;tell assembler what chip we are using


include "P16F628A.inc" ;include the defaults for the chip
ERRORLEVEL 0, -302 ;suppress bank selection messages
__config 0x3D18 ;sets the configuration settings (osc type etc.)
LCD_PORT Equ PORTB
LCD_TRIS Equ TRISB
LCD_RS Equ 0x02 ;LCD handshake lines
LCD_E Equ 0x03

CBLOCK 0x20
count ; Counter used when switch pressed has stopped
count1 ; 160us Counter variable
counta ; variables for delay timers
countb ; variables for delay timers
LCDTemp ; 4 bit for LCD
ENDC ;

In the past, we've looked at


reverse-polarity protection
methods which can protect
you from the diseasters of a
D'oh moment. Power
Protection Circuits Power
Protection Circuits - A Closer
Look at the...
READ MORE...

Via Hack-A-Day: Eagle +


Boards with
Customized Shapes
Matrix/Game Shield +
Project (Firewing)
A Look at Switching +
DC-DC Converters
+
Firewing Color TFT
Library
1 2 3 4 5
6

WHOS ONLINE
We have 29 guests and 0
members online

org 0x000 ;
goto Init ;

MEMBER ACCESS
HEX_Table
addwf PCL, f
retlw 0x30
retlw 0x31
retlw 0x32
retlw 0x33

Username

Remember me
converted by Web2PDFConvert.com

retlw 0x34
retlw 0x35
retlw 0x36
retlw 0x37
retlw 0x38
retlw 0x39
retlw 0x41
retlw 0x42
Asretlw
there is0x43
no real "setup" guide for the 16F628(A) on the digital-diy.com site - I might make one up as I think the
retlw
0x44
little
$2 chip
is worth the time.
retlw 0x45
retlw 0x46

Remember me
Login
Forgot login?
Register

Related Articles
Text
Swordfish
addwf
PCL, f Tutorial - LCD...
Proton
retlw
'H' Tutorial - LCD...
retlw
'e' Tutorial - Analogue To Digital Conversion (...
Proton
retlw
'l'
Download
PIC Compilers...
retlw 'l'
Simple
PIC-based
Anger Meter...
retlw 'o'
retlw ' '
Tags: Assembly, LCD, MPASM, MPLAB
retlw 'W'
Hide comments
(0)
Add comment
retlw
'o'
retlw 'r'
retlw 'l'
retlw 'd'
Noretlw
comments.
'!'
retlw 0x00

Comments

Text2
addwf
retlw
retlw
retlw
retlw
retlw

PCL, f
'L'
'C'
'D'
' 'empowering creative people
'i'

converted by Web2PDFConvert.com

Das könnte Ihnen auch gefallen