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

📄 lcd.asm

📁 利用psoc进行usb及capsense的程序编写
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME:   LCD.asm
;;  Version: 1.4, Updated on 2005/01/10 at 15:21:46
;;  Generated by PSoC Designer ver 4.2  b1013 : 02 September, 2004
;;
;;  DESCRIPTION: LCD User Module software implementation file
;;               for 22/24/25/26/27xxx PSoC family of devices.
;;
;; This set of functions is written for the common 2 and 4 line
;; LCDs that use the Hitachi HD44780A controller.
;;
;;  LCD connections to PSoC port
;;
;;    PX.0 ==> LCD D4
;;    PX.1 ==> LCD D5
;;    PX.2 ==> LCD D6
;;    PX.3 ==> LCD D7
;;    PX.4 ==> LCD E
;;    PX.5 ==> LCD RS
;;    PX.6 ==> LCD R/W
;;
;;  NOTE: User Module APIs conform to the fastcall16 convention for marshalling
;;        arguments and observe the associated "Registers are volatile" policy.
;;        This means it is the caller's responsibility to preserve any values
;;        in the X and A registers that are still needed after the API functions
;;        returns. For Large Memory Model devices it is also the caller's 
;;        responsibility to perserve any value in the CUR_PP, IDX_PP, MVR_PP and 
;;        MVW_PP registers. Even though some of these registers may not be modified
;;        now, there is no guarantee that will remain the case in future releases.
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress MicroSystems 2001-2003. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************

include "m8c.inc"
include "memory.inc"
include "LCD.inc"

;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------

export   LCD_Start
export  _LCD_Start
export   LCD_Init
export  _LCD_Init

export   LCD_WriteData
export  _LCD_WriteData

export   LCD_Control
export  _LCD_Control

export  LCD_PrString
export _LCD_PrString

export  LCD_PrCString
export _LCD_PrCString

export  LCD_Position
export _LCD_Position

export  LCD_PrHexByte
export _LCD_PrHexByte

export  LCD_PrHexInt
export _LCD_PrHexInt

export  LCD_Delay50uTimes
export _LCD_Delay50uTimes

export  LCD_Delay50u
export _LCD_Delay50u

;-----------------------------------------------
; If bargraph functions not required, don't
; export the function names.
;-----------------------------------------------

IF (LCD_BARGRAPH_ENABLE)
export  LCD_InitBG
export _LCD_InitBG

export  LCD_InitVBG
export _LCD_InitVBG

; NOTE: The two functions,
;
;    LCD_DrawVBG and
;    LCD_DrawBG
;
; are implemented using both fastcall16 and legacy fastcall16 because they
; fall into a special and rare case where the calling sequences specified
; by the two disciplines are incompatible. The fastcall16 versions are
; provided for both C and Assembly users in all memory models. The legacy
; fastcall16 versions are provided only to support existing small memory
; model assembly language code---they do not work in the large memory
; model.
;
; ** The legacy fastcall16 versions are provided on a temporary basis to
; ** ease the transition to the 4.2 release of PSoC Designer. Their use is
; ** deprecated and thier status is "No Further Maintenance".
;
; The fastcall16 versions of these functions are distinguished by a
; leading underscore in the name. The legacy fastcall16 names (which appear
; in this comment) do not have the leading underscore. Details on the
; calling sequence to be used for fastcall16 are given in the user module
; datasheet.
;
; Fastcall16 versions:
export _LCD_DrawVBG
export _LCD_DrawBG

IF SYSTEM_SMALL_MEMORY_MODEL
; Legacy Fastcall versions:
export  LCD_DrawVBG
export  LCD_DrawBG
ENDIF  ; SYSTEM_SMALL_MEMORY_MODEL

ENDIF  ; BARGRAPH_ENABLE

;
; The following functions are deprecated and will be eliminated in a future
; version of PSoC Designer.
;
export   LCD_Write_Data
export  _LCD_Write_Data


;-----------------------------------------------
;  EQUATES
;-----------------------------------------------
LCD_E:              equ    10h
LCD_RW:             equ    40h
LCD_RS:             equ    20h

LCD_DATA_MASK:      equ    0Fh
LCD_READY_BIT:      equ    08h

LCD_DATA_READ:      equ    ( LCD_E | LCD_RW | LCD_RS )
LCD_CNTL_READ:      equ    ( LCD_E | LCD_RW )
LCD_PORT_WRITE:     equ    7Fh
LCD_PORT_MASK:      equ    7Fh

LCD_Port:           equ    PRT4DR
LCD_PortMode0:      equ    PRT4DM0
LCD_PortMode1:      equ    PRT4DM1

DISP_INC:           equ    03h
DISP_OFF:           equ    08h
DISP_ON:            equ    0Ch
LCD_4BIT_2LINE:     equ    2Ch


;-----------------------------------------------
;      Bargraph definitions
;-----------------------------------------------

LCD_BG_CHAR_WIDTH:  equ    16     ; 16 characters in width
LCD_BG_SEG_WIDTH:   equ    80     ; 16 * 5 = 80
LCD_BG_COL_START:   equ     0     ; Always start in the left most column

                                  ; Offsets for 2x16, 2x20, 4x20
                                  ; Change these values for a custome LCD

LCD_ROW1_OFFSET:    equ    80h    ; Address/command offset for row 1
LCD_ROW2_OFFSET:    equ    C0h    ; Address/command offset for row 2
LCD_ROW3_OFFSET:    equ    94h    ; Address/command offset for row 1
LCD_ROW4_OFFSET:    equ    D4h    ; Address/command offset for row 2

LCD_BG_ROW1_OFFSET: equ    80h    ; Address/command offset for row 1
LCD_BG_ROW2_OFFSET: equ    C0h    ; Address/command offset for row 2

CG_RAM_OFFSET:      equ    40h    ; Offset to character RAM

AREA UserModules (ROM, REL)

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: LCD_PrCString
;
;  DESCRIPTION:
;    Print constant (ROM) string to LCD
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;     A:X  Pointer to String
;          A contains MSB of string address
;          X contains LSB of string address
;
;  RETURNS:  none
;
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
;    Currently only the page pointer registers listed below are modified: 
;          CUR_PP
;
 LCD_PrCString:
_LCD_PrCString:
    RAM_PROLOGUE RAM_USE_CLASS_1
 Loop_PrCString:
    push  A                            ; Store ROM pointer
    push  X
    romx                               ; Get character from ROM
    jnz   LCD_PrCString_WR             ; print character and advance pointer
    pop   X                            ; Restore the stack
    pop   A
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret                                ; Return

LCD_PrCString_WR:
    call  LCD_WriteData                ; Write data to LCD
    pop   X                            ; Get ROM pointer
    pop   A
    inc   X                            ; Inc LSB of pointer
    jnc   Loop_PrCString
    inc   A                            ; Inc MSB of pointer if LSB overflow
    jmp   Loop_PrCString

.ENDSECTION

;-----------------------------------------------------------------------------
;  FUNCTION NAME: LCD_PrHexByte
;
;  DESCRIPTION:
;     Print a byte in Hex (two characters) to current LCD position
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;     A  => (BYTE) Data/char to be printed
;
;  RETURNS: none
;
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
;    Currently only the page pointer registers listed below are modified: 
;          CUR_PP
;
.LITERAL
LCD_HEX_STR::
     DS    "0123456789ABCDEF"
.ENDLITERAL
.SECTION

 LCD_PrHexByte:
_LCD_PrHexByte:
    RAM_PROLOGUE RAM_USE_CLASS_1
    push  A                            ; Save lower nibble
    asr   A                            ; Shift high nibble to right
    asr   A
    asr   A
    asr   A
    and   A,0Fh                        ; Mask off nibble
    index LCD_HEX_STR                  ; Get Hex value
    call  LCD_WriteData                ; Write data to screen
    pop   A                            ; Restore value
    and   A,0Fh                        ; Mask off lower nibble
    index LCD_HEX_STR                  ; Get Hex value
    call  LCD_WriteData                ; Write data to screen
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: LCD_PrHexInt
;
;  DESCRIPTION:
;     Print an Int in Hex (four characters) to current LCD position
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;     A:X Integer value
;         A  contains LSB of Int
;         X  contains MSB of Int
;
;  RETURNS: none
;
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
;    Currently only the page pointer registers listed below are modified: 
;          CUR_PP
;
 LCD_PrHexInt:
_LCD_PrHexInt:
    RAM_PROLOGUE RAM_USE_CLASS_1
    swap  A,X
    call  LCD_PrHexByte                ; Print MSB
    mov   A,X                          ; Move LSB into position
    call  LCD_PrHexByte                ; Print LSB
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: LCD_PrString
;
;  DESCRIPTION:
;     Print (RAM) ASCII string to LCD
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;     A:X contains pointer to string
;         X  contains LSB of string pointer
;         A  contains MSB or page of string pointer (not used at this time)
;
;  RETURNS:
;
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
;    Currently only the page pointer registers listed below are modified: 
;          CUR_PP

⌨️ 快捷键说明

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