📄 gyromousev1_2.lst
字号:
(0112) ;
(0113) ; The following assumes that the RX buffer feature has been enabled.
(0114) ;
(0115) ; SIDE EFFECTS:
(0116) ; There are 3 posible errors that may occur with the serial port.
(0117) ; 1) Parity Error
(0118) ; 2) Framing Error
(0119) ; 3) OverRun Error
(0120) ;
(0121) ; This user module check for parity and framing error. If either of these
(0122) ; two errors are detected, the data is read and ignored. When an overRun
(0123) ; error occurs, the last byte was lost, but the current byte is valid. For
(0124) ; this reason this error is ignored at this time. Code could be added to
(0125) ; this ISR to set a flag if an error condition occurs.
(0126) ;
(0127) ; THEORY of OPERATION:
(0128) ; When using the RX buffer feature, the ISR collects received characters
(0129) ; in a buffer until the user defined command terminator is detected. After
(0130) ; the command terminator is detected, the command bit is set and all other
(0131) ; characters will be ignored until the command bit is reset. Up to
(0132) ; buffer_size - 1 characters will be collected waiting for a command
(0133) ; terminator. After that, the characters will be discarded, although
(0134) ; a command determinator will still cause the command bit to be set.
(0135) ;
(0136) ;-----------------------------------------------------------------------------
(0137) _UART_1_RX_ISR:
(0138)
(0139) ;@PSoC_UserCode_BODY_2@ (Do not change this line.)
(0140) ;---------------------------------------------------
(0141) ; Insert your custom code below this banner
(0142) ;---------------------------------------------------
(0143) ; NOTE: interrupt service routines must preserve
(0144) ; the values of the A and X CPU registers.
(0145)
(0146) ;---------------------------------------------------
(0147) ; Insert your custom code above this banner
(0148) ;---------------------------------------------------
(0149) ;@PSoC_UserCode_END@ (Do not change this line.)
(0150)
(0151) IF (UART_1_RXBUF_ENABLE)
(0152) push A
0350: 08 PUSH A
(0153) push X
0351: 10 PUSH X
(0154)
(0155) IF SYSTEM_LARGE_MEMORY_MODEL
(0156) REG_PRESERVE IDX_PP
(0157) ENDIF
(0158)
(0159) mov X,[UART_1_bRxCnt] ; Load X with byte counter
0352: 58 84 MOV X,[132]
(0160) mov A,REG[UART_1_RX_CONTROL_REG] ; Read the control register
0354: 5D 2F MOV A,REG[47]
(0161) push A ; Store copy for later test
0356: 08 PUSH A
(0162) ; IF real RX interrupt
(0163) and A,UART_1_RX_REG_FULL ; Did really really get an IRQ
0357: 21 08 AND A,8
(0164) jnz .UARTRX_ReadRx ; Data ready, go get it
0359: B0 04 JNZ 0x035E
(0165) pop A ; Restore stack
035B: 18 POP A
(0166) jmp .RESTORE_IDX_PP
035C: 80 3B JMP 0x0398
(0167)
(0168) .UARTRX_ReadRx:
(0169) pop A ; Restore status flags
035E: 18 POP A
(0170) ; IF there is no error, get data
(0171) ; Check for parity or framing error
(0172) and A,UART_1_RX_ERROR
035F: 21 E0 AND A,224
(0173) jz .UARTRX_NO_ERROR ; If there is not an Error go read data
0361: A0 11 JZ 0x0373
(0174)
(0175) or [UART_1_fStatus],A ; Set error flags (parity,framing,overrun) bits
0363: 2C 83 OR [131],A
(0176) mov A,REG[UART_1_RX_BUFFER_REG ] ; Read the data buffer to clear it.
0365: 5D 2E MOV A,REG[46]
(0177) and A,UART_1_RX_FRAMING_ERROR ; Check for framing error special case
0367: 21 20 AND A,32
(0178) jz .RESTORE_IDX_PP ; Not framing error, all done
0369: A0 2E JZ 0x0398
(0179)
(0180) ; Disable and re-enable RX to reset after
(0181) ; framing error.
(0182) and REG[UART_1_RX_CONTROL_REG], ~UART_1_RX_ENABLE ; Disable RX
036B: 41 2F FE AND REG[47],254
(0183) or REG[UART_1_RX_CONTROL_REG], UART_1_RX_ENABLE ; Enable RX
036E: 43 2F 01 OR REG[47],1
(0184) jmp .RESTORE_IDX_PP ; Done with framing error, leave.
0371: 80 26 JMP 0x0398
(0185)
(0186)
(0187) .UARTRX_NO_ERROR:
(0188) mov A,REG[UART_1_RX_BUFFER_REG ] ; Read the data buffer
0373: 5D 2E MOV A,REG[46]
(0189)
(0190) ; IF buffer not full
(0191) tst [UART_1_fStatus],UART_1_RX_BUF_CMDTERM ; Check for buffer full
0375: 47 83 01 TST [131],1
(0192) jnz .RESTORE_IDX_PP ; All done
0378: B0 1F JNZ 0x0398
(0193)
(0194) cmp A,UART_1_CMD_TERM ; Check for End of command
037A: 39 0D CMP A,13
(0195) jnz .UARTRX_CHK_CTLCHAR
037C: B0 09 JNZ 0x0386
(0196) or [UART_1_fStatus],UART_1_RX_BUF_CMDTERM ; Set command ready bit
037E: 2E 83 01 OR [131],1
(0197)
(0198)
(0199)
(0200) RAM_SETPAGE_IDX >UART_1_aRxBuffer
(0201) RAM_CHANGE_PAGE_MODE FLAG_PGMODE_10b
(0202) mov [X + UART_1_aRxBuffer],00h ; Zero out last data
0381: 56 9F 00 MOV [X-97],0
(0203) RAM_CHANGE_PAGE_MODE FLAG_PGMODE_00b
(0204) jmp .RESTORE_IDX_PP
0384: 80 13 JMP 0x0398
(0205)
(0206) .UARTRX_CHK_CTLCHAR: ; Ignore charaters below this value
(0207) ; If ignore char is set to 0x00, do not
(0208) ; ignore any characters.
(0209) IF(UART_1_RX_IGNORE_BELOW)
(0210) cmp A,UART_1_RX_IGNORE_BELOW
(0211) jc .RESTORE_IDX_PP
(0212) ENDIF
(0213)
(0214) .UARTRX_CHK_OVFL: ; Check for MAX String here
(0215)
(0216) RAM_SETPAGE_IDX >UART_1_aRxBuffer ; using idexed address mode
(0217) cmp [UART_1_bRxCnt],(UART_1_RX_BUFFER_SIZE - 1)
0386: 3C 84 0F CMP [132],15
(0218) jc .UARTRX_ISR_GETDATA
0389: C0 09 JC 0x0393
(0219) RAM_CHANGE_PAGE_MODE FLAG_PGMODE_10b
(0220) mov [X + UART_1_aRxBuffer],00h ; Zero out last data in the buffer
038B: 56 9F 00 MOV [X-97],0
(0221) RAM_CHANGE_PAGE_MODE FLAG_PGMODE_00b
(0222) or [UART_1_fStatus],UART_1_RX_BUF_OVERRUN ; Set error flags (parity,framing,overrun) bits
038E: 2E 83 10 OR [131],16
(0223) jmp .RESTORE_IDX_PP
0391: 80 06 JMP 0x0398
(0224)
(0225) .UARTRX_ISR_GETDATA: ; IF input data == "CR", then end of command
(0226) ; X is already loaded with pointer
(0227) RAM_CHANGE_PAGE_MODE FLAG_PGMODE_10b
(0228) mov [X+UART_1_aRxBuffer],A ; store data in array
0393: 54 9F MOV [X-97],A
(0229) RAM_CHANGE_PAGE_MODE FLAG_PGMODE_00b
(0230) inc X ; Inc the pointer
0395: 75 INC X
(0231) mov [UART_1_bRxCnt],X ; Restore the pointer
0396: 5A 84 MOV [132],X
(0232) ; ENDIF max string size
(0233) .RESTORE_IDX_PP:
(0234) IF SYSTEM_LARGE_MEMORY_MODEL
(0235) REG_RESTORE IDX_PP
(0236) ENDIF
(0237)
(0238) .END_UARTRX_ISR:
(0239) pop X
0398: 20 POP X
(0240) pop A
0399: 18 POP A
(0241)
(0242) ENDIF
(0243)
(0244) UART_1_RX_ISR_END:
(0245) reti
039A: 7E RETI
FILE: lib\uart_1.asm
(0001) ;;*****************************************************************************
(0002) ;;*****************************************************************************
(0003) ;; Filename: UART_1.asm
(0004) ;; Version: 5.2, Updated on 2005/09/30 at 16:26:37
(0005) ;; Generated by PSoC Designer ver 4.2 b1013 : 02 September, 2004
(0006) ;;
(0007) ;; DESCRIPTION: UART User Module software implementation file for the
(0008) ;; 22/24/25/26/27xxx families.
(0009) ;;
(0010) ;;
(0011) ;; NOTE: User Module APIs conform to the fastcall16 convention for marshalling
(0012) ;; arguments and observe the associated "Registers are volatile" policy.
(0013) ;; This means it is the caller's responsibility to preserve any values
(0014) ;; in the X and A registers that are still needed after the API functions
(0015) ;; returns. For Large Memory Model devices it is also the caller's
(0016) ;; responsibility to perserve any value in the CUR_PP, IDX_PP, MVR_PP and
(0017) ;; MVW_PP registers. Even though some of these registers may not be modified
(0018) ;; now, there is no guarantee that will remain the case in future releases.
(0019) ;;-----------------------------------------------------------------------------
(0020) ;; Copyright (c) Cypress MicroSystems 2000-2003. All Rights Reserved.
(0021) ;;*****************************************************************************
(0022) ;;*****************************************************************************
(0023)
(0024)
(0025) include "m8c.inc"
(0026) include "memory.inc"
(0027) include "UART_1.inc"
(0028)
(0029) ;-----------------------------------------------
(0030) ; Global Symbols
(0031) ;-----------------------------------------------
(0032) ;-------------------------------------------------------------------
(0033) ; Declare the functions global for both assembler and C compiler.
(0034) ;
(0035) ; Note that there are two names for each API. First name is
(0036) ; assembler reference. Name with underscore is name refence for
(0037) ; C compiler. Calling function in C source code does not require
(0038) ; the underscore.
(0039) ;-------------------------------------------------------------------
(0040) export UART_1_SetTxIntMode
(0041) export _UART_1_SetTxIntMode
(0042) export UART_1_EnableInt
(0043) export _UART_1_EnableInt
(0044) export UART_1_DisableInt
(0045) export _UART_1_DisableInt
(0046)
(0047) export UART_1_Start
(0048) export _UART_1_Start
(0049) export UART_1_Stop
(0050) export _UART_1_Stop
(0051) export UART_1_SendData
(0052) export _UART_1_SendData
(0053) export UART_1_bReadTxStatus
(0054) export _UART_1_bReadTxStatus
(0055) export UART_1_bReadRxData
(0056) export _UART_1_bReadRxData
(0057) export UART_1_bReadRxStatus
(0058) export _UART_1_bReadRxStatus
(0059)
(0060) export UART_1_IntCntl
(0061) export _UART_1_IntCntl
(0062)
(0063) export UART_1_TxIntMode
(0064) export _UART_1_TxIntMode
(0065)
(0066) export UART_1_PutSHexByte
(0067) export _UART_1_PutSHexByte
(0068) export UART_1_PutSHexInt
(0069) export _UART_1_PutSHexInt
(0070)
(0071) export UART_1_CPutString
(0072) export _UART_1_CPutString
(0073) export UART_1_PutString
(0074) export _UART_1_PutString
(0075) export UART_1_PutChar
(0076) export _UART_1_PutChar
(0077) export UART_1_Write
(0078) export _UART_1_Write
(0079) export UART_1_CWrite
(0080) export _UART_1_CWrite
(0081)
(0082) export UART_1_cGetChar
(0083) export _UART_1_cGetChar
(0084) export UART_1_cReadChar
(0085) export _UART_1_cReadChar
(0086) export UART_1_iReadChar
(0087) export _UART_1_iReadChar
(0088) export UART_1_PutCRLF
(0089) export _UART_1_PutCRLF
(0090)
(0091) IF (UART_1_RXBUF_ENABLE)
(0092) export UART_1_CmdReset
(0093) export _UART_1_CmdReset
(0094) export UART_1_bCmdCheck
(0095) export _UART_1_bCmdCheck
(0096) export UART_1_bCmdLength
(0097) export _UART_1_bCmdLength
(0098) export UART_1_bErrCheck
(0099) export _UART_1_bErrCheck
(0100)
(0101) export UART_1_szGetParam
(0102) export _UART_1_szGetParam
(0103) export UART_1_szGetRestOfParams
(0104) export _UART_1_szGetRestOfParams
(0105) ENDIF
(0106)
(0107) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(0108) ; WARNING WARNING WARNING
(0109) ; The following exports are for backwards compatibility only and should
(0110) ; not be used for new designs. They may be eliminated in a future release.
(0111) ; Their status is "NO FURTHER MAINTENANCE".
(0112) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(0113) export bUART_1_ReadTxStatus
(0114) export _bUART_1_ReadTxStatus
(0115) export bUART_1_ReadRxData
(0116) export _bUART_1_ReadRxData
(0117) export bUART_1_ReadRxStatus
(0118) export _bUART_1_ReadRxStatus
(0119)
(0120) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(0121) ; END WARNING
(0122) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(0123)
(0124) ;-----------------------------------------------
(0125) ; Variable Allocation
(0126) ;-----------------------------------------------
(0127) IF (UART_1_RXBUF_ENABLE)
(0128)
(0129) area UART_1_RAM (RAM, REL, CON)
(0130)
(0131) ptrParam: BLK 1
(0132)
(0133) ENDIF
(0134)
(0135) area text (ROM,REL)
(0136)
(0137) ;-----------------------------------------------
(0138) ; EQUATES
(0139) ;-----------------------------------------------
(0140) bfCONTROL_REG_START_BIT: equ 1 ; Control register start bit
(0141) bfFUNCTION_REG_TX_INT_MODE_BIT: equ 0x10 ; the TX Int Mode bit
(0142)
(0143) area UserModules (ROM, REL, CON)
(0144)
(0145) ;=============================================================================
(0146) ;=============================================================================
(0147) ;
(0148) ; Low-Level Commands
(0149) ;
(0150) ;====================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -