Home

EE-219 - Analog Devices

image

Contents

1. desired state of the RS pin Ue date che byce Or Cara to wreice co the leog ih bftest vait Tor che busy flag CO Clear before Wiesliciling Outputs returned non void writeToLCD int RegisterSelect int data const int Enable 30 ReadWrite 0 int busyflag 1 data spreadData data if obftest while busyflag busyflag busyflag asm bit set flags OxAAAA asm onic Gillie flags 054005356557 8 SRU HTCHHDAT ERBIL NE nanosec 3 SRU LOW DAI_PB15_I nanosec 1 recur O flags rO r0 or 0 flags r0 asm r0 flags r0O r0 or 0 flags r0 O flags rO0O r0 or 0 flags r0 ea int bftest readFromLCD LCDNORS NOWAITFORBF busyflag amp 0x80 gt gt 7 d RegisterSelect lt lt 26 r0 d ReadWrite lt lt 28 r0 aie Ul data lt UaO er Listing 2 writeToLCD Two functions readFromLCbD and writeToLCD are the basis for any other function that will access the LCD The functions supplied in this example are ledinit Listing 3 lecdprintf Listings 4 and 5 ledshiftright Listing 6 lcdshiftleft Listing 7 and ledblink Listing 8 Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 lcdInit performs an initialization routine that is outlined in both the Hitachi HD44780 data sheet 2 and the Optrex LCD Module User s Manual 3 Performing this initialization may not alw
2. their respective holders Information furnished by Analog Devices Applications and Development Tools Engineers is believed to be accurate and reliable however no responsibility is assumed by Analog Devices regarding technical accuracy and topicality of the content provided in Analog Devices Engineer to Engineer Notes For the power interface SHARC EZ KIT Lite development boards provide pins for both a 5V and Ground which can be connected to the Vdd and Vss pins of the LCD module respectively For the Vee connection use a variable potentiometer to control the contrast of the LCD or simply ground Vee for maximum contrast Software The most important step in developing the software for this LCD controller is to emulate the hold times necessary to communicate via the interface This can be done using NOP loops or the timer This example uses NOP loops The entirety of the code to access the LCD as described in this document is included along with a VisualDSP project file ANALOG DEVICES Since this device will handle characters and strings it is most useful to develop the code to interface to the LCD module using the C language The code fragments contained in this document are in C and are compiled using the VisualDSP development suite version 3 0 service pack 1 Code Listings 1 and 2 show the code necessary to read from and write to the device Note that in most cases it is necessary to wait for the de
3. ALOG DEVICES the upper and lower memory locations with the upper locations being shifted to the left by eight locations This is exactly how the lcdprint function operates Specifically it clears the display and returns the cursor to home and writes the entire string up to 40 characters beginning with the first DD RAM location The DD RAM location is then changed to the second line and the string is written again beginning with the ninth character at address 0x40 The rest of the string is written and then the first eight characters are written beginning at address 0x60 This method allows wrapping from the right half of the LCD to the left and vice versa The final three functions supplied are effects on the display and do not change the DD RAM contents AS their names suggest lcdshiftleft and lcdshiftright shift the DD RAM addresses currently displayed The function shifts the display a single character in the specified direction the number of times passed repeated at the interval passed in hundreds of microseconds Similarly ledblink turns the display off and on the number of times passed at the interval passed in hundreds of microseconds IAMEIALIZE the LED as casciesdlloacl iim che HO4AVEO Detcasinecic Inputs passed none Outputs returned non vVordiimi ELED int readbyte dummybyte tlagwalues Handle the parallel port interrupt using ppInterruptVector interrupt SIG_P
4. Engineer to Engineer Note EE 219 ANALOG Technical notes on using Analog Devices DSPs processors and development tools Contact our technical support at dsp support analog com and at dsptools support analog com DEVICES Or visit our on line resources http www analog com ee notes and http www analog com processors Connecting Character LCD Panels to ADSP 21262 SHARC DSPs Contributed by Brian M Introduction This document contains example code and hardware to interface an ADSP 21262 SHARC DSP to a Hitachi HD44780 compatible character LCD driver The specific module used in this example is an Optrex DMC 16128 which has a 16x1 character dot matrix LCD controlled by the HD44780 driver A character LCD module interfaced to the DSP can prove to be a very useful tool In addition to providing a user interface the character device can be used as a real time debugging interface Using the character device to print the function currently executing or the state of buffers while running is a viable alternative to halting the processor to check these states when using an emulator Hardware Interface The critical control signals on the LCD driver are constrained by timing specifications that are slow They are too slow to be used with the Parallel Port However using software to control general purpose flags it is possible to generate the necessary waveforms This method will work for any DSP that provides at least 11 bi directiona
5. Listing 5 Icdprintf Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 6 of 11 ANALOG DEVICES Shift the contents of the LCD to the left Inputs passed number of times to repeat the shift Ut interval between the shifts Outputs returned non void lcdshiftleft int number int interval int i flagvalues Set up the DSP to access the LCD setupForLCD amp flagvalues for 1 0 i lt number i microsec interval PMMeieS thie smire lert Ceunmmeincl writeToLCD LCDNORS 0x18 WAITFORBF finishedWithLCD amp flagvalues Tae blaeial Listing 6 Icdshiftleft Shift the contents of the LCD to the right Inputs passed number of times to repeat the shift ih interval between the shifts Outputs returned non void lcdshiftright int number int interval int i flagvalues setupForLCD amp flagvalues for 1 0 i lt number i microsec interval Write the shift right command writeToLCD LCDNORS 0x1C WAITFORBF finishedWithLCD amp flagvalues IOS bein Listing 7 lcdshiftright Blink the contents of the LCD Inputs passed number of times to blink Ue DUIcECiOiM Char tche LCD ie om oitic Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 7 of 11 ANALOG DEVICES Outputs returned non void lcdbl
6. P ppInterruptVector Set up DAI pin 15 as an output that is low SRUM HOW DATEE Bai 1 i SRU LOW PBEN15_1 Set up the DSP to access the LCD Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 4 of 11 ANALOG DEVICES setupForLCD amp flagvalues Wait for 15 ms microsec 150 writeToLCD LCDNORS 0x30 NOWAITFORBF Wait for 4 1 ms miero ee Ail p writeToLCD LCDNORS 0x30 NOWAITFORBF Wait for 100 us microsec 1 writeToLCD LCDNORS 0x30 NOWAITFORBF writeToLCD LCDNORS 0x38 NOWAITFORBF writeToLCD LCDNORS 0x08 WAITFORBF writeToLCD LCDNORS 0x01 WAITFORBF writeToLCD LCDNORS 0x07 WAITFORBF writeToLCD LCDNORS 0x0C WAITFORBF finishedWithLCD amp flagvalues return Listing 3 initLCD merine aisem co ila ICID Inputs passed the string to be printed Outputs returned non nnGluelie clomalinien Char kaspay int i flagvalues Set up the DSP to access the LCD setupForLCD amp flagvalues Set up the interface writeToLCD LCDNORS 0x3C WAITFORBF Turn on the display with no cursor writeToLCD LCDNORS 0x0C WAITFORBF Set the mode to increment the address by one and shift to the right writeToLCD LCDNORS 0x06 WAITFORBF T the string is too long for the display memory say so if str
7. ation to save the current value of the flags register Outputs returned non void setupForLCD int flagvalues int dummy asm SO0O flags d flagvalues OxA8000000 OxA8000000 asm flags asm flags RAE SMSCWL SPP WILE Ss 2 SRW CLOW IOVAIL Jeri OSDI PETUERE Restore the DSP to the state before accessing the LCD Inputs passed Pointer to the location which contains the saved value of flags register Outputs returned non void finishedWithLCD int flagvalues the Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 9 of 11 ANALOG DEVICES int dummy SRU LOW DAI_PB15_1I SRU LOW PBEN15_1I REG SYSCTL amp OxXFFFFFFFE PPELGS alsin ie lage s0 7 3s gm flagvalues asm flags 0 d flagvalues ESTEUEN Spread a byte of data to match the FLAGS register Inputs passed data byte of data to spread Outputs returned ehe Dye quivalent of the input int spreadData int data ame ay mask 0xff for i 7 i gt 0 i mask mask gt gt 1 data mask amp data Oxffffffff mask amp data lt lt 1 return data Unspread a byte of data to match the FLAGS register Inputs passed data byte of data to unspread Outputs returned the 2 byt quivalent of the input int despreadData int data alge Sly newdata 0
8. ays be necessary but using it will guarantee that the LCD is in its initial state before any commands are set Page 3 of 11 ledprintf is a macro that parses a string in the same manner as a standard printf The ledprint function is called by the ledprintf macro to display the desired characters and the sprintf function is called by the macro to handle the arguments that are passed At this time if no arguments are to be passed it is necessary to call the ledprint function directly as the preprocessor cannot handle a call without any arguments and the variable length argument functions in the C runtime are not functioning The display for the 16x1 character LCD of the DMC 16128 must be accessed as 2 lines each displaying 8 characters at a time The first eight characters are accessed by DD RAM addresses 0x0 through 0x27 and the last eight characters are accessed by addresses 0x40 through 0x67 When reading or writing a string of more than eight characters to the LCD it is necessary to write the first eight characters to the lower addresses in succession then change the DD RAM address to the upper address and write the final characters The LCD driver has the ability to shift the characters already in DD RAM to the right or to the left However these commands do not automatically wrap the contents of the second line to the first or vice versa Therefore it is necessary to program the entire string into both AN
9. ink int number int interval int i flagvalues setupForLCD amp flagvalues for 1 0 i lt number i microsec interval Turn the display off writeToLCD LCDNORS 0x08 WAITFORBF microsec interval Turn the display on writeToLCD LCDNORS 0x0C WAITFORBF finishedWithLCD amp flagvalues Te Sie lei 9 Listing 8 Icdblink The final code listings provide the rest of the SHARC DSPs Since these DSPs do not have functions used in the code above This code and any multiplexing of their programmable flag interface can be ported easily to be compatible pins it is not necessary to use a DAI pin for the with either the ADSP 21161 or ADSP 21065 enable signal Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 8 of 11 Appendix ANALOG DEVICES Pause for a multiple of 100 us Inputs passed duration in units of 100 us Mou puc or ecuried non void microsec int duration algae alle Ora elt O sik lt lt lint auten Taye LET aem Hilcntr 20000 co Gpe umcil leer X NOP A return Pause for a multiple of 100 ns Inputs passed duration in units of 100 ns Outputs returned non void nanosec int duration aioe SLA RO SO a eoe on a asia Uae nites 710 do pe D unei iiee N nop return Set up the DSP to access the LCD Inputs passed Pointer to loc
10. l programmable flags in the SHARC family of DSPs the ADSP 21065 ADSP 21161 and ADSP 21262 provide enough programmable flags to implement this interface This will allow both reading and writing capabilities with an 8 bit interface The HD44780 compatible drivers Rev 1 December 16 2003 can also operate with a 4 bit interface if fewer general purpose flag pins are available ADSP 21262 Optrex DMC 16128 Figure 1 Hardware Interface On the ADSP 21262 SHARC DSP the Parallel Port pins are multiplexed with the general purpose flag pins Therefore any access to the Parallel Port also disturbs the LCD interface To avoid this problem it is necessary to use one of the DAI pins as a general purpose flag so that the enable signal to the LCD will never be changed unintentionally As shown in Figure 1 the final interface implementation requires no glue logic Each of the 11 control pins for the HD44780 driver are connected to a unique programmable flag pin when connecting to the ADSP 21262 SHARC DSP connect the E pin of the HD44780 to the DAI pin being used a programmable flag as described above Copyright 2003 Analog Devices Inc All rights reserved Analog Devices assumes no responsibility for customer product design or the use or application of customers products or for any infringements of patents or rights of others which may result from Analog Devices assistance All trademarks and logos are property of
11. len display gt 40 Lecloriime Sicwiine ioe home p return jiCleaw the display writeToLCD LCDNORS 0x01 WAITFORBF Return the cursor to home writeToLCD LCDNORS 0x02 WAITFORBF Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 5 of 11 ANALOG DEVICES For when the string is less than 8 characters if strlen display lt 8 for i 0 i lt strlen display i writeToLCD LCDRS display i WAITFORBF Saire the cursor tO cine last chars writeToLCD LCDNORS 0xE0 WAITFORBF i Wreice che last charts for i 0 i lt strlen display i writeToLCD LCDRS display i WAITFORBF For all other cases else irite cirst OG Chars for i 0 1i lt strlen display i writeToLCD LCDRS display i WAITFORBF f Siaire che cursor oO che last chars writeToLCD LCDNORS 0xC0 WAITFORBF Write the last 8 chars for i 0p al lt Siciellein Clisjoileny 18 t writeToLCD LCDRS display i 8 WAITFORBF f SMMEC the cursor co che last 8 Chairs writeToLCD LCDNORS 0xE0 WAITFORBF Write the last 8 chars ic re L O p a lt 2 aisha writeToLCD LCDRS display i WAITFORBF finishedWithLCD amp flagvalues recan Listing 4 Icdprint define lcdprintf sting sprintf sting sting __VA_ARGS__ ILe Cloiwslioe Sie LING
12. mask 1 for i 0 i lt 8 i newdata mask amp data mask lt lt 1 data gt gt 1 return newdata Listing 9 Other useful functions Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 10 of 11 ANALOG DEVICES References 1 How to Interface an LCD to the 21xx and 2106x Family DSP s EE 37 09 97 Analog Devices Inc 2 Hitachi HD44780U LCD II Datasheet Rev 0 0 09 99 Hitachi Ltd 3 Optrex Dot Matrix Character LCD Module User s Manual Optrex Corp Document History Revision Description Rev 1 December 16 2003 Initial Version by Brian M Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 11 of 11
13. vice to be ready before performing an actual read or write Part of the call to the read and write function is a Boolean variable bftest Busy Flag Test indicating this requirement At the end of this document is a complete code listing that contains the minor functions called from the listings presented here Raa Ezom the LED Inputs passed Md bftest Outputs returned the byt int readFromLCD int RegisterSelect const int ReadWrite 1 int data busyflag 1 if obftest while busyflag busyflag busyflag asm bit clr flags O0x5400AAAA RegisterSelect Indicates the desired state of the RS pin wait for the busy flag to clear before writing Qu cara reac trom ere IWCD int bftest readFromLCD LCDNORS NOWAITFORBF busyflag amp 0x80 gt gt 7 asm r0 flags r0O r0 or 0 flags r0 d RegisterSelect lt lt 26 r0 asia ie0 iclacgsp cO0Sic0 or s07 tlags icOpsgve CaSeachiieilice lt lt 23 a VOW p nanosec 1 SUR aLGlsl VAIL JPiesiL Sil amp nanosec 3 asim Vic0Siclagsp cleaOxS5555 SM i0 ame wilgvsY ci cece sgvieO Vieil SRU LOW DAI_PB15_I nanosec 1 Connecting Character LCD Panels to ADSP 21262 SHARC DSPs EE 219 Page 2 of 11 ANALOG DEVICES data despreadData data return data Listing 1 readFromLCD Write to the LCD Inputs passed RegisterSelect Indicates the

Download Pdf Manuals

image

Related Search

Related Contents

  Paxton PROXIMITY Energy saving  Canon DC210 Camcorder User Manual  5 - Deep!sonic  User's Manual  D-Series¹  SIMPLE PUMP ADA100 HANDBOOK 5-13-2009  CATALOGO 2012-2013  OK LUB II  Samsung YH-820MC Instrukcja obsługi  

Copyright © All rights reserved.
Failed to retrieve file