📄 timer.asm
字号:
;;Established date: 2005/09/01
;;********************************************************************
;;transmit data from HT82M99E to MCU device
SBR_USBToMCU:
SET F_TimerInterruptEnable
SNZ INTC.3
CLR F_TimerInterruptEnable
CLR INTC.3
MOV A,R_FIFOBAK0
MOV R_OutputReportDataSize,A
MOV A,OFFSET R_FIFOBAK1
MOV MP0,A
L_USBToMCU:
MOV A,r0
CALL SBR_TransmitToMCUDevice
INC MP0
SDZ R_OutputReportDataSize
JMP L_USBToMCU
; MOV A,0FFFH
; MOV R_OutputReportDataSize,A
SZ F_TimerInterruptEnable
SET INTC.3
RET
;;********************************************************************
;;receive data from MCU TO HT82M99E for test
ISR_Timer1:
SZ PB.2
RETI
SZ PB.2
RETI
MOV R_AccTimer,A
MOV A,STATUS
MOV R_StatusTimer,A
MOV A,MP0
MOV R_MP0Timer,A
; INC R_TestCounter
; SNZ R_TestCounter.4
; JMP NOT_SEND_DATA
; CLR R_TestCounter
MOV A,LOW Table_TestCode
MOV TBLP,A
MOV A,OFFSET R_ReceiveBuffer
MOV MP0,A
LOOP_READTEST:
TABRDL R0
INC MP0
INC TBLP
MOV A,TBLH
AND A,00111111B
XOR A,3FH
SNZ Z
JMP LOOP_READTEST
SET F_DataReady
NOT_SEND_DATA:
CLR TMR1C.4
CLR INTC.6
MOV A,R_MP0Timer
MOV MP0,A
MOV A,R_StatusTimer
MOV STATUS,A
MOV A,R_AccTimer
SET TMR1C.4
RETI
;;********************************************************************
;;receive data from MCU TO HT82M99E
ISR_Timer:
SZ PB.2
RETI
SZ PB.2
RETI
MOV R_AccTimer,A
MOV A,STATUS
MOV R_StatusTimer,A
MOV A,MP0
MOV R_MP0Timer,A
MOV A,0FFH
MOV R_ReadWatch_L,A
MOV A,00bH
MOV R_ReadWatch_H,A ;1ms
Wait_PB_2High_Start:
SDZ R_ReadWatch_L
JMP No_Time_out0
SDZ R_ReadWatch_H
JMP No_Time_out0
JMP Wrong_packet_read
No_Time_out0:
SNZ PB.2
JMP Wait_PB_2High_start
SNZ PB.2
JMP Wait_PB_2High_start ;wait high
MOV A,PA
SUB A,0AAH ;packet start flag
SNZ Z
JMP Wrong_packet_read
MOV A,09H
MOV R_ReadCounter,A
MOV A,OFFSET R_ReceiveBuffer
MOV MP0,A
Loop_Read_Next_Data:
MOV A,0FFH
MOV R_ReadWatch_L,A ;85us
Wait_PB_2Low_1:
SDZ R_ReadWatch_L
JMP No_Time_out1
JMP Wrong_packet_read
No_Time_out1:
SZ PB.2
JMP Wait_PB_2Low_1
SZ PB.2
JMP Wait_PB_2Low_1
MOV A,0FFH
MOV R_ReadWatch_L,A ;85us
Wait_PB_2High_1:
SDZ R_ReadWatch_L
JMP No_Time_out2
JMP Wrong_packet_read
No_Time_out2:
SNZ PB.2
JMP Wait_PB_2High_1
SNZ PB.2
JMP Wait_PB_2High_1
MOV A,PA
MOV R0,A
INC MP0
SDZ R_ReadCounter
JMP Loop_Read_Next_Data
MOV A,R_ReceiveBuffer_last ;;Check packet last flag 0xbb
SUB A,0BBH
SNZ Z
JMP Wrong_packet_read
SET F_DataReady
Wrong_packet_read:
CLR TMR1C.4
CLR INTC.6
MOV A,R_MP0Timer
MOV MP0,A
MOV A,R_StatusTimer
MOV STATUS,A
MOV A,R_AccTimer
SET TMR1C.4
RETI
;;********************************************************************
SBR_TransmitToMCUDevice:
RET
;;********************************************************************
;;********************************************************************
SBR_ClearFIFOBAK:
CLR R_FIFOBAK0
CLR R_FIFOBAK1
CLR R_FIFOBAK2
CLR R_FIFOBAK3
CLR R_FIFOBAK4
CLR R_FIFOBAK5
CLR R_FIFOBAK6
CLR R_FIFOBAK7
RET
;;********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -