?? cryosc.asm
字號:
;-----------------------------------------------------------------------------
; cryosc.ASM
;-----------------------------------------------------------------------------
; Copyright 2001, Cygnal Integrated Products, Inc.
;
; FILE: cryosc.ASM
; DEVICE: C8051F02x
; ASSEMBLER: Keil A51
; AUTH: BW
; DATE: 23 JUL 01
;
; This program provides an example of how to configure the C8051F02x device
; to operate from an external 22.1184MHz crystal attached to the XTAL1 and
; XTAL2 pins. Also enables Missing Clock Detector.
;
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
; EQUATES
;-----------------------------------------------------------------------------
$INCLUDE (C8051F020.inc)
LED EQU P1.6 ; LED on target board ('1' is LED ON)
SYSCLK EQU 22118 ; SYSCLK frequency in kHz
;-----------------------------------------------------------------------------
; VARIABLES
;-----------------------------------------------------------------------------
;-------------------
; STACK
STACK SEGMENT IDATA ; declare STACK segment
RSEG STACK
DS 80h ; reserve 128 bytes for stack
;-----------------------------------------------------------------------------
; MACRO DEFINITIONS
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
; RESET AND INTERRUPT VECTOR TABLE
;-----------------------------------------------------------------------------
CSEG AT 0
ljmp Main ; RESET vector
;-----------------------------------------------------------------------------
; MAIN PROGRAM CODE
;-----------------------------------------------------------------------------
CRYOSC SEGMENT CODE ; declare CODE segment
RSEG CRYOSC ; select CODE segment
USING 0 ; using register bank 0
Main:
mov WDTCN, #0deh ; disable watchdog timer
mov WDTCN, #0adh
mov SP, #STACK-1 ; init stack pointer
mov OSCXCN, #67h ; enable external crystal
; oscillator at 22.1184MHz
clr A ; wait at least 1ms
djnz acc, $ ; wait ~512us
djnz acc, $ ; wait ~512us
osc_wait: ; poll for XTLVLD-->1
mov a, OSCXCN
jnb acc.7, osc_wait
orl OSCICN, #08h ; select external oscillator as
; system clock source
orl OSCXCN, #80h ; enable missing clock detector
sjmp $ ; spin forever
;-----------------------------------------------------------------------------
; End of file.
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -