📄 main.asm
字号:
.include "C:\OPENice\Include\Reg\s3c94A5.reg"
.include "ram.reg"
ORG 0000H
VECTOR 00H,INT_94A5
INT_94A5:
tcm INTPND1,#01H ;是否是外部中断REMOTE
jp Z,EXTER_INT6 ;
tcm INTPND1,#08H ;是否是外部中断CD_CLK
jp Z,EXTER_INT1 ;
tcm INTPND2,#40H ;是否是外部中断TAPE_A
jp Z,EXTER_INT7 ;
tcm INTPND2,#04H ;TAPE_B
jp Z,EXTER_INT2 ;
tcm INTPND3,#01H ;5MS
jp Z,INT_TIMER0
tcm INTPND3,#04H ;1000MS
jp Z,INT_TIMER1
tcm INTPND3,#10H ;200US
jp Z,INT_TIMER2
IRET
ORG 3CH
DB 0FFH
DB 0FFH
DB 0FFH
DB 00H
;--------------<< Clear all data registers from 00h to 5Fh >>
ORG 100H
RESET:
DI ; Disable interrupt
ld BTCON,#10100011B ; Watchdog disable
ld CLKCON,#00011000B ; Select non-divided CPU clock
ld SP,#0AFH ; Set stack pointer
ld R0,#0 ; RAM clear
RAM_CLR:
clr @R0 ;
inc R0 ;
cp R0,#0AFH ;
jp ULE,RAM_CLR
;*****TIME2 SETTING*******
ld T0CON,#00100110B ; 5ms
ld T0DATAH,#000H
ld T0DATAL,#0EAH
ld T1CON,#00100100B ;FX/256
ld T1DATAH,#0B7H
ld T1DATAL,#1BH
ld T2CON,#01000110B ;200us
ld T2DATA,#25H
call INIT_IO
ld Show_Led_0,#01
ld Show_Led_1,#02
ld Show_Led_2,#03
ld Show_Led_3,#04
EI
;--------------<< Clear all data registers from 00h to 5Fh >>
;-------------------------------------------------------------------------
;=========================================================
;=========================================================
;=========================================================
;=========================================================
;=========================================================
; 主程序开始
;=========================================================
;=========================================================
;=========================================================
;=========================================================
MAIN:
call Get_Remote_Key
;call Display_Temp
call Refresh_Display
jp MAIN
;=========================================================
;=========================================================
;=========================================================
;=========================================================
;=========================================================
; 主程序结束
;=========================================================
;=========================================================
;=========================================================
;=========================================================
;***********************************************************
;************* ********************
;************* INTERRUPT ********************
;************* ********************
;***********************************************************
;*****************************************
; EXTER INT 6 REMOTE
;*****************************************
EXTER_INT6:
push SYM
clr Time_Delay
clr Time_Delay1
tcm Status_1,#STATE_9M_BIT ;判断是否是接收起始码9毫秒状态
jp z,state_first
tcm Status_1,#STATE_2M_BIT ;
jp z,state_third
or Status_1,#STATE_9M_BIT ;设置状态为接收9毫秒
jp ex_int_ret
state_first:
cp Time_Int_Count,#IR_TIME_9000US+IR_TIME_4500US+5*IR_TIME_MARGIN
jp ugt,error_return
cp Time_Int_Count,#IR_TIME_9000US+IR_TIME_4500US-5*IR_TIME_MARGIN
jp ugt,SET_SECN_2MS
cp Time_Int_Count,#IR_TIME_9000US+IR_TIME_2250US-5*IR_TIME_MARGIN
jp ult,error_return
inc Ir_Repeat_Times
jp error_return
SET_SECN_2MS:
or Status_1,#STATE_2M_BIT
and Status_1,#0ffh-STATE_9M_BIT
ld Remote_Bit_Count,#20h ;接收码值长度
jp ex_int_ret
state_third:
cp Time_Int_Count,#IR_TIME_2250US+2*IR_TIME_MARGIN ;允许误差200us
jp ugt,error_return
cp Time_Int_Count,#IR_TIME_1125US-2*IR_TIME_MARGIN ;允许误差200us
jp ult,error_return
;与当中值(1125+2250)/2=1.6ms判断是1或0
sub Time_Int_Count,#(IR_TIME_2250US+IR_TIME_1125US)/2
rrc Remote_Cmd_Code1
rrc Remote_Cmd_Code0
rrc Remote_Sys_Code1
rrc Remote_Sys_Code0
dec Remote_Bit_Count
jp nz,ex_int_ret
set_ok:
;遥控码接收完毕
clr Ir_Repeat_Times
or Status_1,#IR_KEY_OK_BIT
or Status_1,#IR_KEY_DOWN_UP_BIT
error_return:
;初始化接收状态
and Status_1,#0ffh-STATE_2M_BIT
or Status_1,#STATE_9M_BIT
ex_int_ret:
clr Time_Int_Count
;*********************************************
Exent_Int0_ret:
and INTPND1,#0FEH ; 是否是外部中断
pop SYM
iret
;*****************************************
; EXTER INT 1 CD CLK
;*****************************************
EXTER_INT1:
push SYM
;****************************************************
and INTPND1,#0F7H ; 是否是外部中断
pop SYM
IRET
;*****************************************
; EXTER INT P5.0
;*****************************************
EXTER_INT2:
push SYM
and INTPND2,#0FBH; 是否是外部中断
pop SYM
IRET
;*****************************************
; EXTER INT P4.7
;*****************************************
EXTER_INT7:
push SYM
and INTPND2,#0BFH;
pop SYM
IRET
;*****************************************
; TIME0 INT 5MS
;*****************************************
INT_TIMER0:
push SYM
inc Show_Time_5ms
inc delay_5ms
and INTPND3,#0FEH
pop SYM
iret
;*****************************************
; TIME1 INT 1SEC
;*****************************************
INT_TIMER1:
push SYM
and INTPND3,#0FBH
pop SYM
iret
;*****************************************
; TIME2 INT 200US
;*****************************************
INT_TIMER2:
push SYM
;------------------------------
;超过120毫秒后表示遥控按键己弹起
;------------------------------
inc Time_Int_Count
inc Time_Delay
cp Time_Delay,#30
jp ne,return_t_int
inc Time_Delay1
clr Time_Delay
cp Time_Delay1,#19
jp ne,return_t_int
clr Time_Delay1
clr Time_Delay
and Status_1,#0ffh-IR_KEY_DOWN_UP_BIT ;按键弹起
and Status_1,#0ffh-STATE_9M_BIT ;
return_t_int:
ld INTPND3,#0EFH;TIME2
pop SYM
iret
;*****************************************
;*****************************************
;.include ".\src\18b20\18b20.asm"
.include "sys_init.asm"
.include "remote_key.asm"
.include "show_led.asm"
.include "time.asm"
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -