f360_blinky.asm

来自「8051试验程序 基础教材」· 汇编 代码 · 共 83 行

ASM
83
字号
;-----------------------------------------------------------------------------
; F360_Blinky.asm
;-----------------------------------------------------------------------------
; Copyright 2006 Silicon Laboratories, Inc.
; http://www.silabs.com
;
; Program Description:
;
; This program illustrates how to disable the watchdog timer,
; configure the Crossbar, configure a port and write to a port
; I/O pin.
;
;
; How To Test:
;
; 1) Download code to a 'F36x target board
; 2) Ensure that pins 5 and 6 are shorted together on the J12 header
; 3) Run the code and if the P3.2 LED blinks, the code works
;
;
; FID:            36X000046
; Target:         C8051F36x/F37x
; Command Line:   None
;
; Release 1.0
;    -Initial Revision (GP)
;    -12 DEC 2006
;

#include <ioc8051f360.h>               ; Include register definition file.

;------------------------------------------------------------------------------
; EQUATES
;------------------------------------------------------------------------------

GREEN_LED	EQU	P3.2	; Green LED: '1' is ON	
CONFIG_PAGE	EQU	0FH	; SYSTEM AND PORT CONFIGURATION PAGE

;------------------------------------------------------------------------------
; 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 ; declare new code segment
Main:
            ; Disable the WDT.
            anl   PCA0MD, #NOT(040h)   ; Clear Watchdog Enable bit

            ; Use SFRs on the Configuration Page
            mov   SFRPAGE, #CONFIG_PAGE 

            ; Enable the Port I/O Crossbar
            mov   XBR1, #40h           ; Enable Crossbar
            orl   P3MDOUT, #04h        ; Make LED pin output push-pull

            ; 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 + -
显示快捷键?