⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io.doc

📁 一个C style Assembler的source code
💻 DOC
字号:
             T h e   I O   k e y p a d / L C D   I n t e r f a c e(0) OVERVIEW   I often use a keypad/LCD unit with my 8051 stand-alone board to providean I/O interface.  This unit is configured in a specific way, and the io.libsoftware assumes this specific configuration.(1) HARDWARE INTERFACE   (a) Memory Map   The io.lib module assumes that the following registers are mapped toEXTERNAL DATA memory (XBY memory, as referred to in the debugger) asillustrated below:                      Register                  Address                      LR (LCD REGISTER)           e080                      LD (LCD DATA)               e081                      LS (LCD STROBE)            e090                      KD (KEYPAD DATA)            e0a0It assumes that the keypad input has an associated strobe which will trigger theEXTERNAL INTERRUPT 1 pin (INT1) when INT1 is set in falling edge mode.   (b) Keypad   The keypad is assumed to have 16 keys on it.  When INT1 becomes active, thelower order 4 bits of the KD register will contain the numeric code of the keythat was pressed,   (c) Liquid Crystal Display (LCD)   The LCD is assumed to be 4 rows by 20 columns.  The registers LR and LD areused to sending commands, and sending data, respectively.  The strobe register,LS, is used to latch data to or from either of these registers.   To write to LD or LR, write to its memory-mapped address, and then togglethe strobe, LS.  For example:WriteLR:   mov DPTR, #0e080h  ;;; Write A to LR   movx @DPTR, A   mov DPTR, #0e090h  ;;; Toggle LS.   mov A, #1   movx @DPTR, A   mov A, #0   movx @DPTR, AretWriteLD:   mov DPTR, #0e081h ;;; Write A to LD.   movx @DPTR, A   mov DPTR, #0e090h ;;; Toggle LS.   mov A, #1   movx @DPTR, A   mov A, #0   movx @DPTR, AretReadLR:   mov DPTR, #0e080h  ;;; Clear out LR.   movx A, @DPTR   mov DPTR, #0e090h  ;;; Set LS to enable reading.   movx @DPTR, #1   mov DPTR, #0e080h  ;;; Read LR.   movx A, @DPTR   mov DPTR, #0e090h  ;;; Clear LS to complete the reading.   movx @DPTR, #0retReadLD:   mov DPTR, #0e081h  ;;; Clear out LD.   movx A, @DPTR   mov DPTR, #0e090h  ;;; Set LS.   movx @DPTR, #1   mov DPTR, #0e081h  ;;; Read LD.   movx A, @DPTR   mov DPTR, #0e090h  ;;; Clear LS.   movx @DPTR, #0ret   The actual command codes used for the LCD will depend largely on the unititself, and have mostly been "encapsulated" in the IO interface software.  Youwill need to make the appropriate changes to the IO routines for your LCD unit.(2) IO FUNCTIONS   The following is a description of the functions contained in the IOinterface.   (a) Keypad routines       key_init ... Initialize the keypad, set up external interrupt 1.       cgetc ...... Read the keypad data into A.   (b) LCD routines       scr_init ... Initialize the display, and clear it.       clear ...... Clear the display and set the cursor to row 0, column 0       home ....... Set the cursor to row 0, column 0.       set_cursor ... Set the cursor to the mode indicated in the register A.                      A can be a combination of any of the following values:                         DISPLAY_ON:   Turn the display on                         CURSOR_ON:    Turn on the cursor.                         CURSOR_BLINK: Make the cursor blink.       cursor_left, cursor_right ... to move the cursor       shift-left,   shift_right ... to move the display itself.       locate ...... To place the cursor at the point indicated by the                     variables Row and Col.       save_cursor, restore_cursor:                     So save and restore the more recent cursor                     position       cputc ....... Print the character in A out to the display in TTY manner.       cputs ....... Print out an entire string, pointed to by DPTR, to the                     display unit.   (c) Variables   The io.lib software uses 6 bytes of space for variables.  They have beennamed as follows:               Row, Col:       The current cursor position               OldRow, OldCol: The most recent cursor position saved by the                               last call to save_cursor.               Counter: A 2-byte counter.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -