MosL ofLen a mlcroconLroller program musL lnLeracL wlLh Lhe user by uslng lnpuL and ouLpuL devlces LhaL wlll communlcaLe dlrecLly wlLh Lhe human belng Cne of Lhe mosL common devlces ls Lhe LCu Lhe LCu ls generally used Lo ouLpuL cerLaln LexL or message Lo Lhe user 1he Pu44780 was chosen slnce lL ls one of Lhe sLandard dlsplays generally used ln lndusLry and oLher appllcaLlons whlch are LexLbased MosL common LCu dlsplays are 16x2 or 20x2 Lhls means 16 or 20 characLers per llne by 2 llnes consequenLly Lhe 16x2 was chosen for Lhls Lhesls slnce Lhere lsnL Lhe need Lo dlsplay more Lhan 16 characLers per llne uslng one llne for Lhe volLage and Lhe oLher llne for Lhe currenL dlsplay(LargeL and acLual values) 1hls devlce ls deslgned for lnLerfaclng wlLh mlcroconLroller sysLems and ln Lhls ower Supply lL wlll be lnLerfaced wlLh Lhe C8031l020 uesplLe Lhe facL LhaL Lhls LCu ls one of Lhe mosL commonly used models when deallng wlLh dlfferenL manufacLures Lhe devlce mlghL vary a blL ln Lerms of lnLerfaclng lorLunaLely a very popular sLandard exlsLs whlch allows us Lo communlcaLe wlLh Lhe vasL ma[orlLy of LCus regardless of Lhelr manufacLurer 1he sLandard ls referred Lo as Pu44780u whlch refers Lo Lhe conLroller chlp whlch recelves daLa from an exLernal source (ln Lhls case Lhe 8031) and communlcaLes dlrecLly wlLh Lhe LCu
D44780 |n Descr|pt|ons
oftware Des|gn and |mp|ementat|on 321 LCD oftware Lxp|anat|on llrsL Lhe LCu has Lo be lnlLlallzed ln 88lL mode 1hls ls done by dolng a sequence of delays LogeLher wlLh Lhe handllng of Lhe Lnable llne and by seLLlng 8S and 8W Lo 0 1he handllng of Lhe enable conLrol llne ls used Lo noLlfy Lhe LCu LhaL Lhe user ls ready for lL Lo execuLe an lnsLrucLlon LhaL Lhe same user has prevlously prepared on Lhe daLa bus and on Lhe conLrol llnes When communlcaLlng wlLh Lhe LCu Lhe enable llne musL always be pulsed slnce oLherwlse Lhe LCu wlll noL know LhaL youll be sendlng daLa Lo lL 1hls requlres LhaL Lhe enable llne ls seL before and reseL afLer each lnsLrucLlon ls senL Lo Lhe LCu regardless of wheLher Lhe lnsLrucLlon ls read/wrlLe LexL/lnsLrucLlon So lL ls lmporLanL LhaL before any lnLeracLlon wlLh Lhe LCu Lhe Lnable llne musL be pulled low AfLer pulslng Lhe enable llne one musL ensure LhaL Lhe dlsplay ls cleared 1hls wlll also be done as a sequence of sLeps so Lhe clearlng of Lhe screen musL be made as a baslc funcLlon so LhaL lL can be used frequenLly 1hen afLer Lhe screen ls cleared Lhe daLa wlll be wrlLLen on Lhe LCu ln Lhe wrlLlng process Lhe LCu sLaLus wlll be checked Lo see wheLher lLs busy or noL 1he LCu memory can be represenLed wlLh Lhe followlng memory map Above as seen from Lhe memory map Lhe locaLlons marked ln blue shows Lhe vlslble characLer dlsplay whlch ls 16 characLers long by 2 llnes and each box conLalns lLs memory address SubsequenLly lf one wanLs Lo wrlLe aL a cerLaln poslLlon on Lhe LCu Lhe locaLlon can be referred wlLh Lhe correspondlng address 8uL Lhls counLs only for Lhe flrsL llne whlch sLarLs aL poslLlon 00h Llll Lhe 16Lh characLer whlch ls aL address 0lh 47 Lhen Lhe flrsL characLer of Lhe second llne ls aL address 40h Lherefore we need Lo order Lhe LCu Lo puL Lhe cursor poslLlon aL Lhe second llne 1he seL cursor poslLlon" lnsLrucLlon ls 80h so Lhls value musL be added LogeLher wlLh Lhe acLual deslred cursor poslLlon 1o sum up for Lhe word Pello Lo be wrlLLen from Lhe flrsL characLer ln Lhe flrsL llne ln Lhe program one should allocaLed Lhe world aL 00h+80h 80h Lherefore Lhe word world ls seL aL poslLlon 40h+80h C0h
for (l0 l 236 l++) // walL for osclllaLor Lo sLarL #lfndef SlMuLA1C8 whlle (!(CSCxCn 0x80)) // WalL for crysLal osc Lo seLLle #endlf CSClCn 0x88 // selecL exLernal osclllaLor as S?SCLk // source and enable mlsslng clock // deLecLor