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

📄 black_plane-tx-v2.37.asm

📁 空调风扇控制程序带风扇
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;*******************************************************************************
; FILENAME	: Black_plane-TX
; AUTHOR	: Hu Zhiyan
; PURPOSE	: Template Code for SN8P1602B
; REVISION	: 10/05/2004 V1.0	First issue
;*******************************************************************************
;*  (c) Copyright 2004, Kodec development CO., LTD.
;*******************************************************************************
;///////////////////////////////////////////////////////////////////////////////////////
;		V
;		V1.3
;   		V1.35  将测试模式的10秒进入睡眠改为5秒,充电指示灯
;		V1.36  清除在睡眠模式时,按充电按钮,绿灯闪烁一下问题
;		V1.37  将4分钟后进入睡眠改为15分钟
;
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

CHIP	SN8P1602B					; Select the CHIP
//{{SONIX_CODE_OPTION
	.Code_Option	OSG		Enable
	.Code_Option	High_Clk	4M_X'tal
	.Code_Option	High_Clk/2	Disable
	.Code_Option	Security	Enable
;	.Code_Option	LVD		Enable
	.Code_Option	Watch_Dog	Disable
	.Code_Option	Low_Power	Enable
	.Code_Option	Noise_Filter	Enable
	.Code_Option	Int_16K_RC	By_CPUM
//}}SONIX_CODE_OPTION

;-------------------------------------------------------------------------------
;			Include Files
;-------------------------------------------------------------------------------
.nolist							; do not list the macro file

	INCLUDESTD		MACRO1.H
	INCLUDESTD		MACRO2.H
	INCLUDESTD		MACRO3.H

.list							; Enable the listing function
	
;-------------------------------------------------------------------------------
;			Constants Definition
;-------------------------------------------------------------------------------
;	ONE		EQU	1

;-------------------------------------------------------------------------------
;			Variables Definition
;-------------------------------------------------------------------------------
.DATA
			org	0h			;Data section start from RAM address 0
	Wk00		DS	1			;Temporary buffer for main loop
	Iwk00		DS	1			;Temporary buffer for ISR
	AccBuf		DS	1			;Accumulater buffer
	PflagBuf	DS	1			;PFLAG buffer

	flag3		equ	09h
	flag1		equ	10h
	flag2		equ 	11h
	keyinbuf	equ	12h
	keychkbuf	equ	13h
	keycvtbuf	equ	14h
	key_value	equ	15h
	key_count	equ	16h
  	LEDbuf		equ	17h
	txdata		equ	18h
;
	data_length	equ	1ah
	low_times	equ	1bh
	time50ms	equ	1ch
	time500ms	equ 	1dh
	time4s		equ	1eh
	times4	        equ     1fh
;
	sleep_time	equ   	20h
	charge_time	equ	21h

	key_start	equ	flag1.0
	nokeypress	equ	flag1.1
	RED_flash_enable	equ	flag1.2	
	charge_start	equ	flag1.3 ;?????????????????????????????????????
	LED_on		equ	flag1.4
	time50ms_ok	equ	flag1.5
	detect_led_on	equ	flag1.6
	charge_ok	equ	flag1.7
;
	bitok		equ	flag2.0
	code_start	equ	flag2.1
	code_head	equ 	flag2.2
	code_sycn	equ 	flag2.3
	code_data	equ	flag2.4	
	code_current_data_ok  	equ 	flag2.5
	code_all_data_ok	equ	flag2.6
	before			equ	flag2.7
;
	TX_enable	equ	flag3.0
	charge_continue	equ	flag3.1
	wait_charge	equ	flag3.2

;
        p0buf           equ     p0
        p1buf           equ     p1
        p1mbuf          equ     p1m
        p2buf           equ     p2
        p2mbuf          equ     p2m
         
;-------------------------------------------------------------------------------
;			Bit Variables Definition
;-------------------------------------------------------------------------------

	Wk00B0	    	EQU     Wk00.0 		     	;Bit 0 of Wk00
	Iwk00B1		EQU     Iwk00.1  	   	;Bit 1 of Iwk00
 
;-------------------------------------------------------------------------------
;			Code section
;-------------------------------------------------------------------------------
.CODE								

		ORG	0				;Code section start
	jmp		Reset				;Reset vector
							;Address 4 to 7 are reserved
		ORG	8				
	jmp		Isr				;Interrupt vector

		ORG	10h
;-------------------------------------------------------------------------------
; 			Program reset section
;-------------------------------------------------------------------------------
Reset:
	mov 	    	A,#07Fh				;Initial stack pointer and
   	b0mov 		STKP,A				;disable global interrupt
    	b0mov		PFLAG,#00h			;pflag = x,x,x,x,x,c,dc,z
	mov     	A,#40h				;Clear watchdog timer and initial system mode
	b0mov   	OSCM,A

    	call    	ClrRAM				;Clear RAM
    	call    	SysInit				;System initial
    	b0bset  	FGIE				;Enable global interrupt

;-------------------------------------------------------------------------------
; 			Main routine
;-------------------------------------------------------------------------------
Main:
	b0bset		FWDRST				;Clear watchdog timer

     	call		Mnscan_key			; scan key 

 	call            MnRF_TX				; RF TX

 	call            Application

        call		Mntime_count			; time count

	call		MnLED				; LED indicator

	jmp		Main

;-------------------------------------------------------------------------------
; 			Main application
;-------------------------------------------------------------------------------
Application:
; 	b0bts1		key_value.6
; 	jmp		App_Normal			; to normal mode
; 	jmp		App_Charge			; to charge mode
app_Normal:


        b0bclr		wait_charge			; added on 2004/10/16

	b0bts1		charge_continue			; when mode the change,will stop the charge mode
	jmp		nor1
        b0bclr		charge_continue
        b0bclr		RED_flash_enable
	b0bclr		LEDbuf.2
	b0bset		LEDbuf.6
	b0bclr		LEDbuf.7
	b0bclr		charge_start	
	b0bclr		charge_ok

nor1:	
	b0bset		TX_enable	; enable tx
	b0bset		LEDbuf.6
	mov		a,#0fh
	and		a,key_value
	b0bts1		fz		; if z=1,the acc is zero
	jmp		app_normal10
	jmp		app_normal20
app_normal10:
        clr             time4s                     ; if there's key pressed,will clear the 4s count
        clr		sleep_time

        b0bts1		code_all_data_ok           ; if the data transmit ok,will get next data
        jmp		app90
	b0bclr		code_all_data_ok
	b0bts0		key_value.0		   ; detect the landing key	
	jmp		landing
	b0bts0		key_value.1		   ; detect the turbo key
	jmp		turbo
	b0bts0		key_value.2		   ; detect the left key
	jmp		left
	b0bts0		key_value.3		   ; detect the right key
	jmp		right
	jmp		app_normal20
	
landing:
;	mov 		a,#12h
;	mov 		txdata,a                   ; get the landing code 
	b0bclr		TX_enable			; disable TX
	jmp		app90
turbo:
;	mov		a,#22h
;	mov		txdata,a                   ; get the turbo code 
	b0bclr		TX_enable			; disable TX
	jmp		app90
left:
	b0bset		TX_enable			; disable TX
	mov		a,#42h
	mov		txdata,a                   ; get the left code 
	jmp		app90
right:
	b0bset		TX_enable			; disable TX
	mov		a,#82h
	mov		txdata,a                   ; get the right code 
	jmp		app90


app_normal20:
	b0bclr		TX_enable			; disable TX
	

	clr		txdata
	jmp		app90
;===================================================	
;	
app_Charge:
	b0bclr		LEDbuf.4			; added on 2004/10/20
	
	b0bts0		key_value.4			; added on 2004/10/16
	b0bset		wait_charge			; added on 2004/10/16
	b0bts0		wait_charge			; added on 2004/10/16
	jmp		n12				; added on 2004/10/16
	jmp		to_sleep			; added on 2004/10/16	
n12:							; added on 2004/10/16



	b0bclr		TX_enable			; disable TX
	b0bts1		key_value.5                    ; 1=if the low power p2.1is low
	jmp		charge10

   ;	b0bset		LEDbuf.6   ;////////////////////////////////////
  ;	b0bclr		LEDbuf.6  
;
	b0bts0		charge_continue
	jmp		ccharge

;         
	b0bts1		key_value.4                    ; p2.3
	jmp		app_stop_charge10
ccharge:        
	b0bts0		charge_ok
	jmp		app_stop_charge20

	clr             time4s                     ; if there's key pressed,will clear the 4s count
	clr		sleep_time

        b0bts1		charge_start

	clr		times4

;	b0bts1		charge_start
;        clr		charge_time

	b0bset		charge_continue
        b0bclr		LEDbuf.6
	b0bset		LEDbuf.2
	b0bset		RED_flash_enable
	b0bset		charge_start
	jmp		app90
app_stop_charge10:
	b0bclr		charge_ok		; stop charge
	clr		charge_time
app_stop_charge20:
	b0bclr		charge_continue
        b0bclr		RED_flash_enable
	b0bclr		LEDbuf.2
	b0bts0		charge_ok    ;/////////////////////////////////
	b0bset		LEDbuf.6   
	b0bclr		LEDbuf.7
	b0bclr		charge_start	
	jmp		app90
	
charge10:
	b0bclr		wait_charge			; added on 2004/10/16
	
        b0bclr		charge_continue
        
	b0bts0		charge_start
	b0bset		LEDbuf.6
	
	b0bts1		charge_start
	b0bclr		LEDbuf.6

	b0bclr		RED_flash_enable
	b0bclr		LEDbuf.2
	b0bclr		LEDbuf.7

	b0bts1		key_value.4

	b0bclr		charge_start
	jmp		app90	
	
app90:					
        ret
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
Mnscan_key:
	call		scan_keyin		; get the ports status
	call		scan_keychk		; check the key value
	call		scan_keycvt		; convert the key value
	ret
;
scan_keyin:
   	mov             a,p1buf			; get p1 ports status
   	mov             keyinbuf,a
   	b0bts1 		p0buf.0			; get ports p0.0 status
   	b0bclr		keyinbuf.4
   	b0bts1		p2buf.1			; get ports p2.1 status
   	b0bclr		keyinbuf.5
   	b0bts1  	p2buf.3			; get ports p2.3 status
   	b0bclr		keyinbuf.6
   	b0bts1		p2buf.0			; get ports p2.5 status
   	b0bclr  	keyinbuf.7
   	mov       	a,#0ffh
   	xor		keyinbuf,a
   	
   	ret
;
scan_keychk:
       mov              a,#00h
       cmprs            a,keyinbuf           ; compare the ports value
       jmp              scan_keychk10
       jmp              scan_keychk60        ; no key pressed
scan_keychk10:
       mov              a,keyinbuf
       cmprs            a,keychkbuf
       jmp              scan_keychk20
       b0bts1           key_start
       jmp              scan_keychk90
       decms            key_count             ; detect the key ,will pressed contineu to 100ms
       jmp              scan_keychk70
       mov              a,#64h
       mov              key_count,a
;       mov              a,keychkbuf
;       mov              keycvtbuf,a
       b0bclr           nokeypress
       jmp              scan_keychk90
scan_keychk20:
       mov              a,keyinbuf
       mov              keychkbuf,a              
       mov              a,#64h
       mov              key_count,a           ; set the 100ms original value
       b0bset           key_start
       jmp              scan_keychk90
scan_keychk50:
       clr              key_value
       
scan_keychk60:
       clr		key_value
       b0bclr           key_start
       clr              keychkbuf
scan_keychk70:
       b0bset           nokeypress
scan_keychk90:
       ret
;
scan_keycvt:
	b0bts0 		nokeypress
	jmp		scan_keycvt90
	b0bset 		nokeypress
	mov             a,keychkbuf
	mov     	key_value,a



	b0bts0		key_value.2
  	jmp		scan_keycvt80
	b0bts0		key_value.3
  	jmp		scan_keycvt80
	
	b0bts1		key_value.0
  	jmp		scan_keycvt90
	b0bts1		key_value.1
  	jmp		scan_keycvt90
	b0bts1		key_value.4		; check the detect mode and set 
  	jmp		scan_keycvt90
	b0bset		detect_led_on
	jmp		scan_keycvt90

scan_keycvt80:
	b0bclr		detect_led_on
	clr		sleep_time
	
scan_keycvt90:	
	ret
	
;-------------------------------------------------------------------------------
MnRF_TX:



	b0bts1		bitok			; if the bit transmit ok ,will get the next bit data
	jmp		RF_TX90
	b0bclr		bitok
	b0bts1		code_start
	jmp		RF_TX_code_start       ; transmitting the start code
	b0bts1		code_head
	jmp		RF_TX_code_head		; transmitting the head code
	b0bts1		code_sycn
	jmp		RF_TX_code_sycn		; transmitting the sycn code
	b0bts1		code_data
	jmp		RF_TX_code_data		; transmitting the data code
	jmp		RF_TX_code_wait30ms	; transmitting 30ms interval time
;
RF_TX_code_start:
	decms           data_length	

⌨️ 快捷键说明

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