📄 piconoff.asm
字号:
;**********************************************************************
; *
; Filename: PicOnOff.asm *
; Date: Dec 8th, 2005 *
; File Version: Beta2 (for CBS only) *
; *
; Author: GAiWEi *
; Company: Beijing Grandi *
; *
; *
;**********************************************************************
; *
; Files required: *
; p10F202.inc *
; *
; *
;**********************************************************************
; *
; Notes: *
; *
; *
; *
; *
;**********************************************************************
list p=10F202 ; list directive to define processor
#include <p10F202.inc> ; processor specific variable definitions
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC
ERRORLEVEL -306 ; Get rid of banking messages...
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
#define LED0 GPIO, 0 ; LED 0 at PIN 0
#define LED1 GPIO, 1 ; LED 1 at PIN 1
#define LED2 GPIO, 2 ; LED 2 at PIN 2
#define KEY0 GPIO, 0 ; KEY 0 at PIN 0
#define KEY1 GPIO, 1 ; KEY 1 at PIN 1
#define KEY2 GPIO, 2 ; KEY 2 at PIN 2
#define KEY3 GPIO, 3 ; KEY 3 at PIN 3
;***** VARIABLE DEFINITIONS
state EQU 0x10 ; bit7 - KEY3 state(0-pressed) bit0 - power state(0-off)
count1 EQU 0x11
count2 EQU 0x12
count3 EQU 0x13
;**********************************************************************
ORG 0xFF ; processor reset vector
; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.
ORG 0x000 ; coding begins here
MOVWF OSCCAL ; update register with factory cal value
MOVLW B'00011111'
OPTION
MOVLW B'00001001'
TRIS GPIO
MOVLW B'10000000'
MOVWF state
BCF state, 0
BCF LED1
key3_proc
MOVLW 0x04
MOVWF count3
loop3
MOVLW 0xFF
MOVWF count2
loop2
MOVLW 0xFF
MOVWF count1
loop1
BTFSC KEY3
GOTO key3_up
BCF state, 7
DECFSZ count1, 1
GOTO loop1
DECFSZ count2, 1
GOTO loop2
DECFSZ count3, 1
GOTO loop3
GOTO key3_test
key3_up
BSF state, 7
key3_test
INCF count3, 1
DECFSZ count3, 1
GOTO key3_proc
BTFSS state, 0
GOTO power_on
power_off
BCF LED1
BCF state, 0
GOTO wait_key3up
power_on
BSF LED1
BSF state, 0
wait_key3up
BTFSS KEY3
GOTO $-1
GOTO key3_proc
END ; directive 'end of program'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -