📄 csr_7button_demo_v2_1.lst
字号:
(0110) ;
(0111) ; Fastcall16 versions:
(0112) export _LCD_1_DrawVBG
(0113) export _LCD_1_DrawBG
(0114)
(0115) IF SYSTEM_SMALL_MEMORY_MODEL
(0116) ; Legacy Fastcall versions:
(0117) export LCD_1_DrawVBG
(0118) export LCD_1_DrawBG
(0119) ENDIF ; SYSTEM_SMALL_MEMORY_MODEL
(0120)
(0121) ENDIF ; BARGRAPH_ENABLE
(0122)
(0123) ;
(0124) ; The following functions are deprecated and will be eliminated in a future
(0125) ; version of PSoC Designer.
(0126) ;
(0127) export LCD_1_Write_Data
(0128) export _LCD_1_Write_Data
(0129)
(0130)
(0131) ;-----------------------------------------------
(0132) ; EQUATES
(0133) ;-----------------------------------------------
(0134) LCD_E: equ 10h
(0135) LCD_RW: equ 40h
(0136) LCD_RS: equ 20h
(0137)
(0138) LCD_DATA_MASK: equ 0Fh
(0139) LCD_READY_BIT: equ 08h
(0140)
(0141) LCD_DATA_READ: equ ( LCD_E | LCD_RW | LCD_RS )
(0142) LCD_CNTL_READ: equ ( LCD_E | LCD_RW )
(0143) LCD_PORT_WRITE: equ 7Fh
(0144) LCD_PORT_MASK: equ 7Fh
(0145)
(0146) LCD_Port: equ PRT2DR
(0147) LCD_PortMode0: equ PRT2DM0
(0148) LCD_PortMode1: equ PRT2DM1
(0149)
(0150) DISP_INC: equ 03h
(0151) DISP_OFF: equ 08h
(0152) DISP_ON: equ 0Ch
(0153) LCD_4BIT_2LINE: equ 2Ch
(0154)
(0155)
(0156) ;-----------------------------------------------
(0157) ; Bargraph definitions
(0158) ;-----------------------------------------------
(0159)
(0160) LCD_BG_CHAR_WIDTH: equ 16 ; 16 characters in width
(0161) LCD_BG_SEG_WIDTH: equ 80 ; 16 * 5 = 80
(0162) LCD_BG_COL_START: equ 0 ; Always start in the left most column
(0163)
(0164) ; Offsets for 2x16, 2x20, 4x20
(0165) ; Change these values for a custome LCD
(0166)
(0167) LCD_ROW1_OFFSET: equ 80h ; Address/command offset for row 1
(0168) LCD_ROW2_OFFSET: equ C0h ; Address/command offset for row 2
(0169) LCD_ROW3_OFFSET: equ 94h ; Address/command offset for row 1
(0170) LCD_ROW4_OFFSET: equ D4h ; Address/command offset for row 2
(0171)
(0172) LCD_BG_ROW1_OFFSET: equ 80h ; Address/command offset for row 1
(0173) LCD_BG_ROW2_OFFSET: equ C0h ; Address/command offset for row 2
(0174)
(0175) CG_RAM_OFFSET: equ 40h ; Offset to character RAM
(0176)
(0177) AREA UserModules (ROM, REL)
(0178)
(0179) .SECTION
(0180) ;-----------------------------------------------------------------------------
(0181) ; FUNCTION NAME: LCD_1_PrCString
(0182) ;
(0183) ; DESCRIPTION:
(0184) ; Print constant (ROM) string to LCD
(0185) ;-----------------------------------------------------------------------------
(0186) ;
(0187) ; ARGUMENTS:
(0188) ; A:X Pointer to String
(0189) ; A contains MSB of string address
(0190) ; X contains LSB of string address
(0191) ;
(0192) ; RETURNS: none
(0193) ;
(0194) ; SIDE EFFECTS:
(0195) ; The A and X registers may be modified by this or future implementations
(0196) ; of this function. The same is true for all RAM page pointer registers in
(0197) ; the Large Memory Model. When necessary, it is the calling function's
(0198) ; responsibility to perserve their values across calls to fastcall16
(0199) ; functions.
(0200) ;
(0201) ; Currently only the page pointer registers listed below are modified:
(0202) ; CUR_PP
(0203) ;
(0204) LCD_1_PrCString:
(0205) _LCD_1_PrCString:
(0206) RAM_PROLOGUE RAM_USE_CLASS_1
(0207) Loop_PrCString:
(0208) push A ; Store ROM pointer
0300: 08 PUSH A
(0209) push X
0301: 10 PUSH X
(0210) romx ; Get character from ROM
0302: 28 ROMX
(0211) jnz LCD_PrCString_WR ; print character and advance pointer
0303: B0 04 JNZ 0x0308
(0212) pop X ; Restore the stack
0305: 20 POP X
(0213) pop A
0306: 18 POP A
(0214) RAM_EPILOGUE RAM_USE_CLASS_1
(0215) ret ; Return
0307: 7F RET
(0216)
(0217) LCD_PrCString_WR:
(0218) call LCD_1_WriteData ; Write data to LCD
0308: 90 46 CALL 0x0350
(0219) pop X ; Get ROM pointer
030A: 20 POP X
(0220) pop A
030B: 18 POP A
(0221) inc X ; Inc LSB of pointer
030C: 75 INC X
(0222) jnc Loop_PrCString
030D: DF F2 JNC 0x0300
(0223) inc A ; Inc MSB of pointer if LSB overflow
030F: 74 INC A
(0224) jmp Loop_PrCString
0310: 8F EF JMP 0x0300
0312: 30 HALT
0313: 31 32 XOR A,50
0315: 33 34 XOR A,[X+52]
0317: 35 36 XOR [X+54],A
0319: 37 38 39 XOR [X+56],57
031C: 41 42 43 AND REG[66],67
031F: 44 45 46 OR REG[X+69],70
(0225)
(0226) .ENDSECTION
(0227)
(0228) ;-----------------------------------------------------------------------------
(0229) ; FUNCTION NAME: LCD_1_PrHexByte
(0230) ;
(0231) ; DESCRIPTION:
(0232) ; Print a byte in Hex (two characters) to current LCD position
(0233) ;
(0234) ;-----------------------------------------------------------------------------
(0235) ;
(0236) ; ARGUMENTS:
(0237) ; A => (BYTE) Data/char to be printed
(0238) ;
(0239) ; RETURNS: none
(0240) ;
(0241) ; SIDE EFFECTS:
(0242) ; The A and X registers may be modified by this or future implementations
(0243) ; of this function. The same is true for all RAM page pointer registers in
(0244) ; the Large Memory Model. When necessary, it is the calling function's
(0245) ; responsibility to perserve their values across calls to fastcall16
(0246) ; functions.
(0247) ;
(0248) ; Currently only the page pointer registers listed below are modified:
(0249) ; CUR_PP
(0250) ;
(0251) .LITERAL
(0252) LCD_HEX_STR::
(0253) DS "0123456789ABCDEF"
(0254) .ENDLITERAL
(0255) .SECTION
(0256)
(0257) LCD_1_PrHexByte:
(0258) _LCD_1_PrHexByte:
(0259) RAM_PROLOGUE RAM_USE_CLASS_1
(0260) push A ; Save lower nibble
0322: 08 PUSH A
(0261) asr A ; Shift high nibble to right
0323: 67 ASR A
(0262) asr A
0324: 67 ASR A
(0263) asr A
0325: 67 ASR A
(0264) asr A
0326: 67 ASR A
(0265) and A,0Fh ; Mask off nibble
0327: 21 0F AND A,15
(0266) index LCD_HEX_STR ; Get Hex value
0329: FF E7 INDEX 0x0312
(0267) call LCD_1_WriteData ; Write data to screen
032B: 90 23 CALL 0x0350
(0268) pop A ; Restore value
032D: 18 POP A
(0269) and A,0Fh ; Mask off lower nibble
032E: 21 0F AND A,15
(0270) index LCD_HEX_STR ; Get Hex value
0330: FF E0 INDEX 0x0312
(0271) call LCD_1_WriteData ; Write data to screen
0332: 90 1C CALL 0x0350
(0272) RAM_EPILOGUE RAM_USE_CLASS_1
(0273) ret
0334: 7F RET
(0274) .ENDSECTION
(0275)
(0276) .SECTION
(0277) ;-----------------------------------------------------------------------------
(0278) ; FUNCTION NAME: LCD_1_PrHexInt
(0279) ;
(0280) ; DESCRIPTION:
(0281) ; Print an Int in Hex (four characters) to current LCD position
(0282) ;
(0283) ;-----------------------------------------------------------------------------
(0284) ;
(0285) ; ARGUMENTS:
(0286) ; A:X Integer value
(0287) ; A contains LSB of Int
(0288) ; X contains MSB of Int
(0289) ;
(0290) ; RETURNS: none
(0291) ;
(0292) ; SIDE EFFECTS:
(0293) ; The A and X registers may be modified by this or future implementations
(0294) ; of this function. The same is true for all RAM page pointer registers in
(0295) ; the Large Memory Model. When necessary, it is the calling function's
(0296) ; responsibility to perserve their values across calls to fastcall16
(0297) ; functions.
(0298) ;
(0299) ; Currently only the page pointer registers listed below are modified:
(0300) ; CUR_PP
(0301) ;
(0302) LCD_1_PrHexInt:
(0303) _LCD_1_PrHexInt:
(0304) RAM_PROLOGUE RAM_USE_CLASS_1
(0305) swap A,X
0335: 4B SWAP A,X
(0306) call LCD_1_PrHexByte ; Print MSB
0336: 9F EA CALL 0x0322
(0307) mov A,X ; Move LSB into position
0338: 5B MOV A,X
(0308) call LCD_1_PrHexByte ; Print LSB
0339: 9F E7 CALL 0x0322
(0309) RAM_EPILOGUE RAM_USE_CLASS_1
(0310) ret
033B: 7F RET
(0311) .ENDSECTION
(0312)
(0313) .SECTION
(0314) ;-----------------------------------------------------------------------------
(0315) ; FUNCTION NAME: LCD_1_PrString
(0316) ;
(0317) ; DESCRIPTION:
(0318) ; Print (RAM) ASCII string to LCD
(0319) ;
(0320) ;-----------------------------------------------------------------------------
(0321) ;
(0322) ; ARGUMENTS:
(0323) ; A:X contains pointer to string
(0324) ; X contains LSB of string pointer
(0325) ; A contains MSB or page of string pointer (not used at this time)
(0326) ;
(0327) ; RETURNS:
(0328) ;
(0329) ; SIDE EFFECTS:
(0330) ; The A and X registers may be modified by this or future implementations
(0331) ; of this function. The same is true for all RAM page pointer registers in
(0332) ; the Large Memory Model. When necessary, it is the calling function's
(0333) ; responsibility to perserve their values across calls to fastcall16
(0334) ; functions.
(0335) ;
(0336) ; Currently only the page pointer registers listed below are modified:
(0337) ; CUR_PP
(0338) ; IDX_PP
(0339) ;
(0340) ;
(0341) LCD_1_PrString:
(0342) _LCD_1_PrString:
(0343) RAM_PROLOGUE RAM_USE_CLASS_3
033C: 70 BF AND F,191
(0344) RAM_SETPAGE_IDX A
033E: 60 D3 MOV REG[211],A
(0345) Loop_PrString:
(0346) mov A,[X] ; Get value pointed to by X
0340: 52 00 MOV A,[X+0]
(0347) jz End_LCD_PrString ; Check for end of string
0342: A0 08 JZ 0x034B
(0348) ;LCD_1_writeData is known not to modify X so no need to perserve
(0349) call LCD_1_WriteData ; Write data to screen
0344: 90 0A CALL 0x0350
(0350) inc X ; Advance pointer to next character
0346: 75 INC X
(0351) push X
0347: 10 PUSH X
(0352) pop X
0348: 20 POP X
(0353) jmp Loop_PrString ; Go get next character
0349: 8F F6 JMP 0x0340
034B: 70 3F AND F,63
(0354) End_LCD_PrString:
(0355) RAM_EPILOGUE RAM_USE_CLASS_3
034D: 71 C0 OR F,192
(0356) ret
034F: 7F RET
(0357) .ENDSECTION
(0358)
(0359) .SECTION
(0360) ;-----------------------------------------------------------------------------
(0361) ; FUNCTION NAME: LCD_1_WriteData
(0362) ;
(0363) ; DESCRIPTION:
(0364) ; Write a byte to the LCD's data register.
(0365) ;
(0366) ;-----------------------------------------------------------------------------
(0367) ;
(0368) ; ARGUMENTS:
(0369) ; A contains byte to be written to LCD data register
(0370) ;
(0371) ; RETURNS: none
(0372) ;
(0373) ; SIDE EFFECTS:
(0374) ; The A and X registers may be modified by this or future implementations
(0375) ; of this function. The same is true for all RAM page pointer registers in
(0376) ; the Large Memory Model. When necessary, it is the calling function's
(0377) ; responsibility to perserve their values across calls to fastcall16
(0378) ; functions.
(0379) ;
(0380) ; Currently only the page pointer registers listed below are modified:
(0381) ; CUR_PP
(0382) ;
(0383) LCD_1_WriteData:
(0384) _LCD_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -