LCD Theory

Share Embed Donate


Short Description

Descripción: LCD theory...

Description

1.0 Introduction L CDs t an dsf orL i qui dCr y s t al Di s pl a y .AnL CDi sapas s i v ede vi c e.I tdoesno tpr od uc ean yl i ghtands i mpl yal t er st he l i ghtt r av el l i ngt hr oughi t .Wi t hav ol t ageappl i edt oi t ,t hel i qui dc r y s t al pol ar i z est r ans mi t t edl i ghti nadi ffer entdi r ec t i on t owhennov ol t agei sappl i ed.Apol ar i z i ngfi l t eri nf r ontoft hedi s pl ayt henbl oc ksoneoft het wopol ar i z at i ons( i . e.t he ar e asi nwh i c hav o l t a gewasap pl i e do rt h eo ne swh er en ov o l t a gewasapp l i e d)a ndt h er e f o r ei ns omea r e asoft h e s c r ee nappear‘ bl ac k ’ ,t hi seff ec ti sus edt odr a wt hec har ac t er sandgr aphi c sdi s pl a y edbyanLCD.

Refl ec t i v et wi s t ednemat i cl i qui dc r y s t al di s pl ay 1.Pol ar i z i ngfi l t erfi l m wi t hav er t i c al ax i st opol ar i z el i ghtasi tent er s . 2.Gl as ss ubs t r at ewi t hITO  el ec t r odes .Thes hapesoft hes eel ec t r o deswi l l det er mi n et hes ha pest h atwi l l appear wh ent h eL CDi st u r ne dON.Ver t i c al r i dg ese t c h edont h es ur f a cear es moo mo t h . 3.T wi s t ednemat i cl i qui dc r y s t al . 4.Gl as ss ubs t r at ewi t hc ommonel ec t r odefi l m( I TO)wi t hhor i z ont al r i dgest ol i neupwi t ht hehor i z ont al fi l t er . 5.Pol ar i z i ngfi l t erfi l m wi t hahor i z ont al ax i st obl oc k/ pas sl i ght . 6.Refl ec t i v es ur f ac et os endl i ghtbac kt ov i ewer .( I nabac kl i tL CD,t hi sl ay eri sr epl ac edwi t hal i ghts our c e. ) Al mos tal l L CDshav eas t r ongl i ghts our c ebui l ti nbehi ndagl as spanel ( whi c hc ont ai nst hel i qui dc r y s t al ) ,t hi sens ur es t hatt hear easofl i ghtanddar kont hes cr een( di c t at edbyt hear easont hel i qui dc r y s t al panel ac r os swhi c hav ol t age i sappl i ed)hav egoodc ont r as t .Di s pl a yswi t hnobac kl i ght st hatr el ysol el yont hel i ghti nc i dentont heL CDpanel c annotbeus edi nl owl i ghtc ondi t i ons . Mo s tc o mmo mm nl yu s edc ha r a c t e rb as e dL CDsar eb as e do nHi t a c hi ’ sHD4 47 80c o nt r o l l e ro ro t h erwh i c har ec omp at i b l e wi t hHD44580.I nt hi st ut or i al ,wewi l l di s c us saboutc har ac t erbas edL CDs ,t hei ri nt er f ac i ngwi t hPI Cmi c r oc ont r ol l er s , v ar i ousi nt er f ac es( 8bi t / 4bi t ) ,pr ogr ammi ng,s pec i al s t uffandt r i c k sy ouc andowi t ht hes es i mpl el ook i ngL CDswhi c h c angi v eane wl o okt oy ourappl i c at i on.

2.0 Pin Description Th emo s tc o mmo mm nl yu s e dL CDsf o un di nt h ema r k e tt o da ya r e1L i n e,2Li n eo r4Li n eL CDswh i c hha v eo nl y1 c on t r ol l e ra nds up po r t a tmo s tof80c har ac t er s ,wh er e asL CDss up por t i ngmo mor et h an80ch ar a ct er sma ma k eu seof2 HD44 78 0c on t r o l l e r s . Mos tL CDswi t honec ont r ol l erha v e14pi nsor1 6pi ns( t woex t r api nsar ef orbac k l i ghtLEDc onnec t i ons )whi l eLCDs wi t ht woc ont r ol l er shav et womor epi nst oenabl et headdi t i onal c ont r ol l er .Wewi l l f oc usonL CDswi t honec ont r ol l eri n t hi sar t i c l es i nc ei ti soneoft hec ommonl yus edmodel si nt hemar k et .Li k ewi s e,t heoper at i onsar eappl i c abl ef ort wo c ont r ol l er sLCDaswel l .Pi ndes c r i pt i oni ss howni nt het abl ebel ow.

Ch a r a c t e rL CDc o mmo npi n sd i a g r a m

Char ac t erL CDpi nswi t honecont r ol l er TheHD44780st andar dr eq ui r es3c ont r ol l i nesaswel l a sei t her4or8I / Ol i n esf ort hedat abus .Theus erma ys el ec t whet hert heL CDi st ooper at ewi t ha4bi tdat abusoran8bi tdat abus .I fa4bi tdat abusi sus edt heL CDwi l l r equi r e at ot al of7dat al i nes( 3c ont r ol l i nespl ust he4l i nesf ort hedat abus ) . I fan8bi tdat abusi sus edt heL CDwi l l r equi r e at ot al of11dat al i nes( 3c ont r ol l i nespl ust he8l i nesf ort hedat abus ) . Thet hr eec ont r ol l i nesar er ef er r edt oasEN,RS,a ndRW. TheEN  l i nei scal l ed“ Enabl e. ”Thi scont r ol l i nei sus edt ot el l t heL CDt haty ouar es endi ngi ndat a.T os enddat at o t heL CD,y ourpr o gr am s houl dmak es ur et hi sl i nei sl o w( 0)a ndt hens ett heot hert woc ont r ol l i n esand/ orputdat aon t hedat abus .Whent heot herl i nesar ec ompl et el yr ea dy , br i n g EN  h i g h( 1)a ndwai tf ort hemi n i mu m amo un to ft i me r equi r edbyt heL CDdat as heet( t hi sv ar i esf r om L CDt oL CD) ,anden db ybr i ngi n gi tl o w( 0)agai n. TheRS  l i nei st he“ Regi s t erSel ec t ”l i ne.WhenRSi sl ow( 0) ,t hed at ai st obet r eat edasac ommandors pec i al i ns t r uc t i on( s uc hasc l ears c r een,pos i t i onc ur s or ,et c . ) .WhenRSi shi gh( 1) ,t hedat abei ngs enti st ex tdat awhi c h s oul dbedi s pl a y edont hesc r een.Fore x ampl e,t odi s pl a yt hel et t er“ T”ont hes c r e eny ouwoul ds etRShi g h. TheRW  l i nei st he“ Read/ Wr i t e”c ont r ol l i ne.WhenRW i sl ow( 0) ,t hei nf or mat i onont hedat abusi sbei ngwr i t t ent o t heLCD.WhenRW i shi gh( 1) ,t hepr ogr am i seff ec t i v el yqu er y i ng( orr eadi ng)t heLCD.Onl yonei ns t r uc t i o n( “ Get L CDs t a t u s ” )i sar e adc omma nd .Al l o t h er sa r ewr i t ec omma nd s –s oRW wi l l a l mo s ta l wa y sbel o w. Thedat abusc ons i s t sof4or8l i nes( dependi ngont hemo deofoper at i onsel ec t edbyt heus er ) .I nt h ec as eofan8bi tdat abus ,t hel i nesar er ef er r edt oasDB0,DB1,DB2,DB3,DB4,DB5,DB6,a ndDB7.

Fi nal l y ,t hepowers uppl ypi nsf ort hebac kl i ght– LED  andLED!.So meL CDmo du l e sc omewi t h ou tt h eb ac k l i g ht .I n t h atc as e,t h es epi n sar eno tf ou ndora r el ef td i s c on nec t e d.Th er e c ommen de dv o l t a gef o rL ED+i s4 . 2 Van dL EDs ho ul db ec o nn ec t e dt og r o un d( GND) .Var yt h ev a l u eo ft h er e si s t orc on nec t e dt oL ED+wi l l c ha ng et heb r i g ht n es sof t h eb ac k l i g ht .No r ma l l y , 2 20Oh mo r3 30Ohm r es i s t o rwi l l b eu s ed.Fo ra dv a nc e du s er ,y o uma yc on ne ctt h ep i nt o PWM out putandchanget hebr i g ht n es si ny ours of t war eb ya l t er i ngt hePWM dut yc y c l e.Wewi l l f ur t h erdi s c us st hi si n u pc o mi n gi s s u e s .

3.0 "#rd$#re %onnection At y pi c al L CDhar dwar ec onn ec t i ont oPI Cmi c r oc ont r ol l erwi t hbac k l i gh tt ur nedo nper manent l yi ss howni nfigur e b el o w.T ot u r no fft h eb ac k l i g ht ,d i s c o nn ec tt h es u pp l i e st op i n1 5a nd1 6.RB4 ,RB5a ndRB6o fPI C1 6F8 77 Aa r eu s ed f ort hec ont r ol s i gnal swhi l ePORTDoft hemi c r oc ont r ol l eri st hedat abus .

At y pi c al L CDt oPI Cmi c r oc ont r ol l erhar dwar econnec t i on

4.0 DDR&' ( Disp)#* D#t# R&' Di s pl a yd at aRAM ( DDRAM)s t or e sd i s pl a yd at ar ep r es e nt e di n8 b i tc h ar a ct e rc o d es .I t sex t e nd edc a pa ci t yi s80X8 bi t s ,o r80c h ar a ct e r s .Thea r e ai nd i s p l a yda t aRAM ( DDRAM)t h ati sno tu s edf o rdi s pl a yca nb eu se da sge ne r al d at aRAM.Sowh at e v e ry o us en do nt h eDDRAM i sa c t u al l yd i s p l a y e do nt h eL CD.F orL CDsl i k e1 ×1 6,o nl y1 6 c har ac t er sar ev i s i bl e,s owhat ev ery ouwr i t eaf t er16c har ac t er si swr i t t eni nDDRAM buti snotv i s i bl et ot heus er . Fi g ur e sbe l o wwi l l s h o wy o ut h eDDRAM a dd r e s s e sof1l i n ea nd2l i n esL CDs .

5.0 %+R,' ( %-#r#cter +ener#tor R,' No wy o umi g htb et h i n k i n gt h atwh eny o us e n da nASCI Iv a l u et oDDRAM,h o wt h ec h a r a c t e ri sd i s p l a y e do nL CD?So t h ean s we ri si nCGROM.T heCh a r a c t e rGe n er a t o rROM ( CGROM)g e ne r a t e s5 ×8do t so r5 × 10d ot sc h a r a c t e r pa t t er nsf r om 8bi tc har ac t erc odes( s eefi gur esbel owf ormor ede t ai l s ) .I tc angen er at e2085×8do tc har ac t er pa t t e r nsan d3 25 ×10d otc har a ct e rp at t er n s.Us er de fi ne dc har a ct e rp a t t er n sa r ea l s oa v ai l a bl eb yma sk p r og r amme d ROM.He r ewewi l l o nl yd i s c u s s5 ×8d ot sc h ar a c t e rp at t e r n sLCDmo du l ewh i c hi sc o mmo nl yus e d .

L CDc h a r a c t e r sc o d ema pf o r5 ×8do t s Asy o uc a ns e ei nbo t ht h ec o d ema ps ,t h ec h a r a c t e rc o d ef r o m0 ×0 0t o0× 07i so c c u pi e db yt h eCGRAM c h a r a c t e r s ort heus erdefi nedc har ac t er s .I fus erwant st odi s pl ayt hef our t hc us t om c har ac t ert hent hec odet odi s pl a yi ti s0×03 i . e .whe nu se rs e nd s0×0 3c o det ot h eL CDDDRAM,t h ef o ur t hu s erc r e at e dc ha r a ct e ro rp at t e r nwi l l bedi s pl a y edon t heLCD.

6.0 %+R&' ( %-#r#cter +ener#tor R&' Asi n di c a t e db yi t sna me ,CGRAM a r e ai sus e dt oc r e at ec u s t o mc h ar a c t e r si nL CD.I nt h ec h ar a c t e rg en er a t o rRAM, us erc anr ewr i t ec har ac t erpat t er nsbypr ogr am.For5x8dot s ,ei ghtc har ac t erpat t er nsc anbewr i t t en,andf or5x10 do t s ,f ou rc har ac t erp at t e r nsc anbewr i t t e n.Wewi l l n otc o v erh owt ous eCGRAM ar e at omak ec us t o mc har a ct e r si n t hi st ut or i al .Pl eas es t ayt unef ort hef ut ur ei s sue.

7.0 B ( Bus* )#/ Bu syFl agi sas t a t u si n di c at orfl a gf o rL CD.Whe nwes en dac omma ndord at at ot h eL CDf o rpr o c es s i n g,t h i sfl agi s s et( i . eBF=1)andassoonast hei ns t r uc t i oni sex ec ut eds uc ces sf ul l yt hi sflagi scl ear ed( BF=0) .Thi si shel pf ul i n de t er mi n i n gt h ee x ac ta mo untofd el a yf o rt heLCDp r o c es s . T or e a dBu s yFl a g ,t h ec o n d i t i o nRS=0an dR/ W =1mu s tb eme ta n dt h eMSBo ft h eL CDd a t abu s( D7 )a c t sa s busyfl ag.WhenBF=1meansLCDi sbusyandwi l l notacc eptnext commandordat aandBF=0meansLCDi s r e ad yf o rt h en ex tc o mma ndo rd at at op r o c es s .

.0 Instruction Re/ister IR #nd D#t# Re/ister DR Ther ear et wo8bi tr egi s t er si nHD44780c ont r ol l erI ns t r uc t i onandDat ar egi s t er .I ns t r uc t i onr egi s t erc or r es pondst o t h er e gi s t e rwh er ey o us e n dc o mma nd st oL CDe . gL CDs h i f tc o mma nd ,L CDc l e ar ,L CDa dd r e s se t c .a ndDa t a r egi s t eri sus edf ors t or i ngda t awhi c hi st obedi s pl a y edonL CD.Wh ens endt heenabl es i gnal oft heL CDi sas s er t ed, t h ed at ao nt hepi nsi sl a t c he di nt ot h ed at ar e gi s t e ra ndda t ai st he nmo v edau t o mat i c al l yt ot h eDDRAM an dh en cei s d i s p l a y e do nt h eL CD.Da t aRe gi s t e ri sn oto nl yu s edf o rs e nd i n gd at at oDDRAM b uta l s of o rCGRAM,t h ea dd r e s s wh er ey o uwa ntt os e ndt h ed at a ,i sde c i d edb yt h ei n s t r u c t i o ny o us e ndt oL CD.Wewi l l d i s c u s smo r eo nL CD i ns t r uc t i ons etf ur t heri nt hi st ut or i al .

.0 L%D %o#nds #nd Instruction Set Onl yt h eI ns t r u ct i o nRe gi s t er( I R)a ndt h eDa t aRe gi s t e r( DR)o ft h eL CDc a nb ec on t r ol l e db yt h eMCU.Bef or e s t ar t i ngt hei nt er nal oper at i onoft heL CD,c ont r ol i nf or mat i oni st empor ar i l ys t or edi nt ot hes er egi s t er st oal l ow

i nt er f ac i ngwi t hv ar i ousMCUs ,whi c hoper at eatdi ff er ents peeds ,orv ar i ousper i pher al c ont r ol dev i c es .Thei nt er nal op er at i onoft heL CDi sde t er mi nedb ys i gn al ss entf r om t heMCU.Thes es i gnal s ,whi c hi nc l uder egi s t ers el ec t i on s i gnal ( RS) ,r ead/ wr i t es i gnal ( R/ W) ,andt hedat ab us( DB0t oDB7) ,mak eupt heLCDi ns t r uc t i ons .Ther ear ef our c at egor i esofi ns t r uc t i ons : •

Designate LCD functions, such as display format, data length, etc.



Set internal RAM addresses



erform data transfer !ith internal RAM



erform miscellaneous functions

Co mma nd sa ndI n s t r u c t i o nss e t f o rL CDt y p eHD4 47 80 Al t h ou ghl oo ki n ga tt h et a bl ey o uc anmak ey o uro wnc omman dsandt es tt he m.Bel o wi sabr i e fl i s to fu s ef u l c o mma nd swh i c har ef r e qu en t l yu s edwh i l ewo r k i n go nt h eL CD.

F r e qu en t l yus e dc o mma nd sa ndi n s t r u c t i o ns f orL CD Thet a bl eabo v ewi l l h el py ouwhi l ewr i t i ngpr ogr amsf orL CD.Butaf t ery ouar edo net es t i ngwi t hi t ,Ir ec ommendy ou t ous et hepr ev i oust abl e( ogetmor egr i po nwor k i ng Commands and Instructions set for LCD type HD44780)t wi t hL CDa n dt r y i n gy o u ro wnc o mma n ds .

.0 %onc)usion That ’ sal l f ort hi si s sue.I nt henex tpar toft het ut or i al wewi l l c ont i nuewi t ht hes of t war epr ogr ammi ngf orPI C mi c r o cont r ol l er st oi nt er f ac ewi t ht heLCDmodul e.Pl eas ec ont i nuet of ol l owt hi st opi candl ety ourappl i c at i oni nt er ac t s wi t hy o ut h r o ug hL CD!

L%D Initi#)i#tion I nt hi spar t ,wewi l l s eet hei ni t i al i z at i onwi t hs omeo ft hec odi nge x ampl esi nCus i ngMi c r oc hi pMPLABI DEandHI TECHCPRO c o mp i l e rf o rt h ePI C1 0/ 1 2/ 1 6MCUF ami l y . Th es es of t wa r ear ef r e eo fc h ar g ea ndt h el a t e s tr e l e as e s c a nb eo bt a i n edf r o mb ot hMi c r o c hi pan dHI TECHwe bs i t e s . Bef or eus i ngt heL CDf ordi s pl aypur pos e,L CDhast obei ni t i al i z edei t herbyt hei nt er nal r es etc i r c ui tors endi ngs etof c omman dst ot heLCD.Us erhast odec i dewhe t hera nL CDh ast obei ni t i al i z edbyi ns t r uc t i onsorb yi nt er nal r es et c i r c ui t .Wewi l l di s c us sbot ht y pesofi ni t i al i z at i onher e.

Initi#)i#tion * Intern#) Reset %ircuit Ani nt er nal r es etc i r c ui tau t omat i c al l yi ni t i al i z est heHD447 80Uwhent hepoweri st ur nedon .TheBu syFl ag( BF)i s k epti nt hebus ys t at eunt i l t hei ni t i al i z at i onends( BF=1) .Thebus ys t at el as t sf or10msaf t erVCCr i s est o4. 5V.The f ol l owi ngi ns t r uc t i onsar eex ec ut eddur i ngt hei ni t i al i z at i on. •

Display clear



"unction set# DL $ %& '()it interface data * $ +& %(line display " $ +&  - ' dot character font



Display ono/ control# D $ +& Display o/  C $ +& Cursor o/  0 $ +& 0lin1ing o/ 



2ntry mode set# ID $ %& Increment )y % S $ +& *o shift

Ther ear ec er t ai nc ondi t i onst hathav et obemet ,i fus erwant st ous ei ni t i al i z at i onbyi nt er nal r es etc i r c ui t .Thes e c ondi t i onsar es ho wni nt het a bl ebel o w.

Power supply conditions using internal reset circuit  Fi gur ebel ows howst het es tc ondi t i onswhi c har et obemetf ori nt er nal r es etc i r c ui tt obeac t i v e.

Internal power supply reset  Thepr obl em wi t hi nt er nal r es etc i r c ui ti st hati ti shi ghl ydependentonpowers uppl y .I ti snothar dt omeett hi scr i t i c al powers uppl ycondi t i onsbuti ti sof t endi ffic ul tt oac hi ev ewhens i mpl eappl i c at i onar ei nv ol v ed.Henc e,us ual l yt he s ec ondmet ho d,i ni t i al i z at i onb yi ns t r uc t i oni sus edandi sr ec ommend edmos toft het i me. I ft heel ec t r i c al c har ac t er i s t i c sc ondi t i onsl i s t edundert het abl ePowerSuppl yCondi t i onsus i ngI nt er nal Res etCi r c ui t ar enotmet ,t hei nt er nal r es etc i r c ui twi l l notoper at enor mal l yandwi l l f ai l t oi ni t i al i z et heHD44780U.Fors uc hac as e, i ni t i al i z at i onmus tbeper f or medbyt heMCUasex pl ai nedi nt henex ts ec t i on,I ni t i al i z i ngbyI ns t r uc t i on.

Initi#)i#tion * Instructions I ni t i al i z i ngL CDwi t hi ns t r uc t i onsi sr el at i v el ys i mpl e.Gi v enbel owi safl owc har tt hatdes cr i best hes t ept of ol l owt o i ni t i al i z et heLCD.

Flow chart for LCD 8!it interface initiali"ation Thefir s t3c omma ndsar eus ua l l yno tr e qu i r e db utar er ec omme nd edwh eny oua r eus i n g4 b i ti nt er f a ce .Soac t u al l y y o uc a np r og r am t heL CDs t ar t i n gf r om s e nd i n gf u nc t i o ns etwh enwor k i ngwi t h8b i ti n t e r f ac e.Fu nc t i o ns etc omma nd de pe ndsonwhatk i ndofL CDy ouar eus i ngandwhatk i ndo fi nt er f ac ey ouar eu si ng( r ef ert ot het a bl ei n LCD

Command s ec t i on) . Fo rPI C1 6F8 77 A,t h et y pi c al c o nfi g ur a t i o ns e t t i n gsan dt h ed ec l a r at i ono fL CDp i nsar es ho wni nt h efi gu r eb el o w.

 # typical con$guration settings and declaration of LCD pins for PIC%&F877#

L%D Entr* 'ode Fr om Commands and Instructions set for LCD type HD44780  t abl eat t ac hedatt heendoft hi sar t i c l e,y ouc an s eet h att h er ea r et wobi t swh i c hd et e r mi n et h een t r ymo def o rL CD: a)I / D–I n cr eme nt / De cr e men tb i t b)S–Di s pl ayshi f t . Si n c eb i t2i sal wa y ss et ,weg etf o urc ombi na t i on so fe nt r ymo dewh i c ha r e0×0 4( 1 00 3) ,0×05( 1013) ,0×0 6( 1103)an d 0 ×0 7( 1 1 13) .Soweg etdi ff er entr es ul t swi t ht hes edi ff er entent r ymodes .Nor mal l yent r ymode0×06i sus ed,whi c hi s nos hi f tan daut omat i ci nc r eme nt .Dot r yal l t hepos s i bl eent r ymodesands eet her es ul t s ,Iam s ur ey ouwi l l be s ur pr i s ed.

Programming e'ample for LCD Initiali"ation in C Language Wi t ht hehel po ft heab ov ec od e,y ouar eabl et oi ni t i al i z et heL CD.Thes ampl ec odec ont ai nsaf unc t i on/ s ubr out i ne– L CD_ bu sy . Thi ss ubr o ut i nei sus e dt oc al l f ord el a ys ot h att h er es ho ul dn otb ea nyc omma ndo rd at as e ntt ot h eL CD unt i l i tfi ni s hesex ec ut i ngt hec ommand.Mor eont hi sdel ayr out i nei sex pl ai nedi nt hene xts ec t i on.

%-ecin/ t-e Bus* )#/ Asdi s c us s edi nt h epr e v i o uss ec t i o n,t h er emu s tb es omed el a ywhi c hi snee de dt obet h er ef o rL CDt os uc c es s f ul l y pr o ce sst h ec omma ndo rd at a .Sot hi sdel a yc anb ema deei t h erwi t hadel a yl oo po fs pe ci fi edt i memo r et h ant h ato f L CDp r o c es st i meorwec anr e adt h eb us yfl a g,wh i c hi sr e c omme nd ed .Th er e as o nt ous ebu s yfl agi st h atd el a y pr oduc edi sal mos tt heamountoft i mef orwhi c hL CDn ee dt opr oc es s .So,i ti sbes ts ui t edf ore ver yappl i c at i on.

Steps to Re#d Bus* )#/ Whenwesendt hecommand,t heBForDB7bi toft heLCDbecomes1andassoonast hecommandi spr ocess edt he BF=0.Fo l l o wi n ga r et h es t e pst ob ek e pti nmi n dwhi l er e ad i n gt h eBu syfl ag. •

Select command register



Select read operation



Send ena)le signal



Read the 4ag



So follo!ing the a)o5e steps !e can !rite the code in C as )elo!6

LCD (usy Flag routine in C Language I fy oudonotwantt or eadt hebus yfl agy oucansi mpl yus edel a yr out i nest opr o vi det hespec i fi camoun tofdel a y s. Yo uha v et oma k es ur et h ede l a y sa r er e as on ab l eb yr ef er r i ngt o Commands and Instructions set for LCD type a bl e .Th ee x a mp l ec o dec a nb eo bt a i n eda tCy t r o n’ sSK4 0C( En ha nc e d4 0p i n sPI CSt a r t u pKi t )p r o du c t HD44780 t

p ag e.Bu s yfl a gc an no tb ec he c k e dwh eny o uar eu s i n gSK4 0Cb ec a u s et h eR/ W( Re ad / Wr i t e )p i no fL CDi s c o nn ec t e dt oGr o un dp er ma ne nt l y . Sor e adc omma ndi su na bl et obee x ec u t e da ndde l a yr o ut i n esmu s tb eu s edf o r t heLCDf u nc t i ons .Th emai nr e as ont oha v es uc hdes i gni st or es er v emor ePI CI / Opi nsf orot herap pl i c at i ons . I ti sof t eni mpor t antt oi ni t i al i z et hef unc t i onorus esf unc t i onpr ot ot y pesatt hebegi nni ngoft hepr ogr am ( pl eas er ef ert o s o ur c ec o dep r o v i d edh er e :!!!.ro)othead3toe.com.my ) Nowt hatwear er eadywi t ht hei ni t i al i z at i onr out i neandt hebus yr out i nef orL CD,we’ l l mov eont ot hene xts ec t i onon howt osenddat aandcommandt ot heLCD.

Sendin/ %o#nds to L%D I nor d ert os en dc o mma nd swes i mp l yn ee dt os el e c tt h ec o mma ndr e gi s t e r .Ev e r y t h i n gi ss a measweha v edo nei n t hei ni t i al i z at i onr o ut i ne.Butwewi l l s ummar i z et hecommons t epsandputt hem i nas i ngl es ubr out i ne.Fol l owi ngar e t hes t eps : •

mo5e data to LCD port



select command register



select !rite operation



send ena)le signal



!ait for LCD to process the command

Ke ep i n gt h es es t e psi nmi n dwec anwr i t eL CDc o mma ndr o ut i n ea s :

)outine for LCD send command in C language

Settin/ %ursor Position on L%D T os e tt h ec u r s o rp os i t i o no nL CD,wene edt os e ndt h eDDRAM a dd r e s s . Bit

7

6

5

4

3

2

1

0

8#)ue % AD7 AD AD8 AD9 AD3 AD% AD+ DD)#* address Thes ev e nt hbi ti sal wa y s1,an db i t s0t o6a r eDDRAM a dd r es s( r e f e rt h e LCD Commands and Instruction Set section) .Soi fy ouwantt oputt hec ur s oronfi r s tpos i t i ont headdr es swi l l be’ 0000000i nbi nar yand7t hbi ti s1.The ′ 

a dd r e s swi l l b e1 00 00 00 03  or0 ×8 0,s of o rDDRAM a l l a dd r e s ss t a r t sf r o m0 ×8 0. Fo r2l i ne sa nd16c ha r ac t er sL CD.Th ea dd r e ssf r om 0 ×8 0t o0 x8 Fa r ev i s i bl eonfi r s tl i n ea nd0 xC0t o0 xCFi sv i s i b l e ons ec ondl i ne,t her es toft heDDRAM ar eai sst i l l a vai l abl ebuti snotv i s i bl eont heL CD,i fy ouwantt oc hec kt hi s t hi ng,t hens i mpl yputal ongs t i nggr eat ert han16c har ac t erands hi f tt heent i r edi s pl ay ,y ouwi l l s eeal l t hemi s si ng c har ac t erc omi ngf r om t hebac k .Byt hi swa yy ouc anc r eat es c r ol l i ngl i neonL CD( s eemor eons hi f t i ngdi s pl a y i ncommands section) . Bel owi sanex ampl ef ors et t i ngcur s orpos i t i ononLCD:

 #n e'ample for setting cursor at $rst line+ 4th position

Sendin/ D#t# to L%D I no r d ert os enddat awesi mpl yneedt osel ec tt hedat ar egi s t er .Ev er y t hi ngi ss ameast h ec ommandr out i ne. Fol l o wi n gar et hes t eps :

· mo v ed a t at oL CDp o r t · s el ec tdat ar egi s t er · s el ec twr i t eoper at i on · s en de na bl es i g na l · wai tf orL CDt opr oc es st hedat a

LCD send data routine in C language Yo uha v es e ent h ati t ’ sr e al l ye as yt os en dc omma ndan dd at at oL CD.Wha ti fweh av eas t r i ngt ose ndt oL CD?I t ’ s s i mpl e.Wewi l l s t or et heL CDs t r i ngi nt heROM oft hePI Cmi c r oc ont r ol l erandc al l t hes t r i ngc har ac t erbyc har ac t er .A s i mp l eex a mp l ei ss h o wnbe l o w.

LCD send string routine in C language

%onc)usion I fy ouhav ebeenf ol l owi ngt hi sar t i c l eunt i l t hi sst age,y ous houl dbeabl et oc onfi gur eanddi s pl aychar ac t er sony our L CDmo du l eu s i n gaPI Cmi c r o c on t r o l l e r .Ha v ef u n!Th ef u l l s a mp l es o ur c ec o dec a nb eo bt a i n edf r o m Ro bo t .He adt o T oewe bs i t e( !!!.ro)othead3toe.com.my ) .Pl eas ef ol l owusi nt hene xti s s uef ormor eex pl anat i onont he ad vanc edf eat ur esoft heL CD,s uc hasc r e at i ngcus t om c har ac t er san d4bi tdat ab usi nt er f ac i ng.

Re9ision :eneral information of the LCD, circuit connection to IC microcontroller, soft!are initiali;ation, commands and instruction sets, and the )asic sample program ha5e )een discussed in the pre5ious issues. ence you can display more interesting stu/ on your LCD?

%-#r#cter +ener#tor R#ndo!&ccess 'eor* %+R&' All character )ased LCD of type >D88@'+ has C:RAM. In order to create custom patterns, !e need to store 5alues to the C:RAM de=ning !hich pi-el to glo!. "rom the =gure sho!n )elo!, 7 )its address from D0+ to D0 AC:B is used to access 78 )ytes of C:RAM area.

"igure# C:RAM command and address. ead to ToeEs !e)site, Do!nloadEs section.  The a)o5e =gure sho!s the routine to create smiley character at pattern location %. To display the a)o5e de=ned pattern on LCD, simply call LCDsenddata%B, !here E%G in the su)routine function is the argument

to

indicate

pattern

%.

This

is

sho!n

in

the

C

code

)elo!.

0ottom of "orm "igure# C code to display the user de=ned character, pattern %. More e-amples of custom characters are sho!n in the =gure )elo!. As you can see, !e can e5en com)ine

t!o

standard

characters

into

"igure# More e-ample of custom characters or patterns.

one

'

dots

frame

too.

%onc)usion  The tutorial on custom character ends here. >ope you enNoy creating your o!n custom characters.
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF