blink.asm
来自「8051试验程序 基础教材」· 汇编 代码 · 共 80 行
ASM
80 行
;-----------------------------------------------------------------------------
; Copyright (C) 2005 Silicon Laboratories, Inc.
; All rights reserved.
;
;
;
; FILE NAME : BLINK.ASM
; TARGET MCU : C8051F2xx
; DESCRIPTION : This program illustrates how to disable the watchdog timer,
; configure a port and write to a port I/O pin.
;
; NOTES:
;
;-----------------------------------------------------------------------------
;TARGET MCU : C8051F206, 'F220, 'F221, 'F226, 'F230, 'F231 and F236.
;Uncomment to include SFR declarations for desired derivative
#include <ioC8051F206.h> ; SFR declarations
;#include <ioC8051F220.h> ; SFR declarations
;#include <ioC8051F221.h> ; SFR declarations
;#include <ioC8051F226.h> ; SFR declarations
;#include <ioC8051F230.h> ; SFR declarations
;#include <ioC8051F231.h> ; SFR declarations
;#include <ioC8051F236.h> ; SFR declarations
;-----------------------------------------------------------------------------
; EQUATES
;-----------------------------------------------------------------------------
GREEN_LED equ P2.4 ; Port I/O pin connected to Green LED.
;-----------------------------------------------------------------------------
; RESET and INTERRUPT VECTORS
;-----------------------------------------------------------------------------
; Reset Vector
ASEGN CSEG01:CODE,0
ljmp Main ; Locate a jump to the start of code at
; the reset vector.
;-----------------------------------------------------------------------------
; CODE SEGMENT
;-----------------------------------------------------------------------------
RSEG BLINK:CODE ;Switch to code segement using register bank 0 (by default)
Main: ; Disable the WDT. (IRQs not enabled at this point.)
; If interrupts were enabled, we would need to explicitly
; disable them so that the 2nd move to WDTCN occurs no more
; than four clock cycles after the first move to WDTCN.
mov WDTCN, #0DEh
mov WDTCN, #0ADh
; Set P2.4 (LED) as digital output in push-pull mode.
orl PRT2CF, #10h
orl P2MODE, #10h
; Initialize LED to OFF
clr GREEN_LED
; Simple delay loop.
Loop2: mov R7, #03h
Loop1: mov R6, #00h
Loop0: mov R5, #00h
djnz R5, $
djnz R6, Loop0
djnz R7, Loop1
cpl GREEN_LED ; Toggle LED.
jmp Loop2
;-----------------------------------------------------------------------------
; End of file.
END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?