📄 f220full.asm
字号:
;---------------------------------------------------------------
; CYGNAL Integrated Products
;
; Assembly Code Configuration Tool: F220 INITIALIZATION/CONFIGURATION CODE
;----------------------------------------------------------------
; This file is read only. To insert the code into your
; application, simply cut and paste or use the "Save As"
; command in the file menu to save the file in your project
; directory.
;----------------------------------------------------------------
;----------------------------------------------------------------
; GLOBAL VARIABLES AND ASSIGNMENTS
;----------------------------------------------------------------
$INCLUDE(C8051F200.INC) ; Register definition file.
;----------------------------------------------------------------
; INTERRUPT VECTOR CODE
;----------------------------------------------------------------
org 00h
LJMP Config
; Place jump to reset handler and interrupt service routines here.
Config:
org 0B3h ; End of Interrupt Vector space.
;----------------------------------------------------------------
; Watchdog Timer Configuration
;
; WDTCN.[7:0]: WDT Control
; Writing 0xA5 enables and reloads the WDT.
; Writing 0xDE followed within 4 clocks by 0xAD disables the WDT
; Writing 0xFF locks out disable feature.
;
; WDTCN.[2:0]: WDT timer interval bits
; NOTE! When writing interval bits, bit 7 must be a 0.
;
; Bit 2 | Bit 1 | Bit 0
;------------------------
; 1 | 1 | 1 Timeout interval = 1048576 x Tsysclk
; 1 | 1 | 0 Timeout interval = 262144 x Tsysclk
; 1 | 0 | 1 Timeout interval = 65636 x Tsysclk
; 1 | 0 | 0 Timeout interval = 16384 x Tsysclk
; 0 | 1 | 1 Timeout interval = 4096 x Tsysclk
; 0 | 1 | 0 Timeout interval = 1024 x Tsysclk
; 0 | 0 | 1 Timeout interval = 256 x Tsysclk
; 0 | 0 | 0 Timeout interval = 64 x Tsysclk
;------------------------
mov WDTCN, #007h ; Watchdog Timer Control Register
; Configure the PRTnMX Registers
mov PRT0MX, #000h ; PRT0MX: Initial Reset Value
mov PRT1MX, #000h ; PRT1MX: Initial Reset Value
mov PRT2MX, #000h ; PRT2MX: Initial Reset Value
mov PRT3MX, #000h ; PRT3MX: Initial Reset Value
; Select Pin I/0
; NOTE: Some peripheral I/O pins can function as either inputs or
; outputs, depending on the configuration of the peripheral. By default,
; the configuration utility will configure outputs as push-pull.
; If the I/O direction changes to input once the peripheral is
; configured, the peripheral hardware will override the PRTnCF register
; setting and change the pin configuration to input.
; Port configuration (1 = Push Pull Output)
mov PRT0CF, #000h ; Output configuration for P0
mov PRT1CF, #000h ; Output configuration for P1
mov PRT2CF, #000h ; Output configuration for P2
mov PRT3CF, #000h ; Output configuration for P3
mov P0MODE, #0FFh ; Input Configuration for P0
mov P1MODE, #0FFh ; Input Configuration for P1
mov P2MODE, #0FFh ; Input Configuration for P2
mov P3MODE, #0FFh ; Input Configuration for P3
; View port pinout
; The current MUX configuration results in the
; following port pinout assignment:
; Port 0
; P0.0 = GP I/O (Open-Drain Output/Input)
; P0.1 = GP I/O (Open-Drain Output/Input)
; P0.2 = GP I/O (Open-Drain Output/Input)
; P0.3 = GP I/O (Open-Drain Output/Input)
; P0.4 = GP I/O (Open-Drain Output/Input)
; P0.5 = GP I/O (Open-Drain Output/Input)
; P0.6 = GP I/O (Open-Drain Output/Input)
; P0.7 = GP I/O (Open-Drain Output/Input)
; Port 1
; P1.0 = GP I/O (Open-Drain Output/Input)
; P1.1 = GP I/O (Open-Drain Output/Input)
; P1.2 = GP I/O (Open-Drain Output/Input)
; P1.3 = GP I/O (Open-Drain Output/Input)
; P1.4 = GP I/O (Open-Drain Output/Input)
; P1.5 = GP I/O (Open-Drain Output/Input)
; P1.6 = GP I/O (Open-Drain Output/Input)
; P1.7 = GP I/O (Open-Drain Output/Input)
; Port 2
; P2.0 = GP I/O (Open-Drain Output/Input)
; P2.1 = GP I/O (Open-Drain Output/Input)
; P2.2 = GP I/O (Open-Drain Output/Input)
; P2.3 = GP I/O (Open-Drain Output/Input)
; P2.4 = GP I/O (Open-Drain Output/Input)
; P2.5 = GP I/O (Open-Drain Output/Input)
; P2.6 = GP I/O (Open-Drain Output/Input)
; P2.7 = GP I/O (Open-Drain Output/Input)
; Port 3
; P3.0 = GP I/O (Open-Drain Output/Input)
; P3.1 = GP I/O (Open-Drain Output/Input)
; P3.2 = GP I/O (Open-Drain Output/Input)
; P3.3 = GP I/O (Open-Drain Output/Input)
; P3.4 = GP I/O (Open-Drain Output/Input)
; P3.5 = GP I/O (Open-Drain Output/Input)
; P3.6 = GP I/O (Open-Drain Output/Input)
; P3.7 = GP I/O (Open-Drain Output/Input)
;----------------------------------------------------------------
; Comparators Register Configuration
;
; Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
;------------------------------------------------------------------
; R/W | R | R/W | R/W | R/W | R/W | R/W | R/W
;------------------------------------------------------------------
; Enable | Output | Rising | Falling| Positive | Negative
; | State | Edge | Edge | Hysterisis | Hysterisis
; | Flag | Int. | Int. | 00: Disable | 00: Disable
; | | Flag | Flag | 01: 5mV | 01: 5mV
; | | | | 10: 10mV | 10: 10mV
; | | | | 11: 20mV | 11: 20mV
; ----------------------------------------------------------------
mov CPT0CN, #000h ; Comparator 0 Control Register
mov CPT1CN, #000h ; Comparator 1 Control Register
;Comp1 marker
;----------------------------------------------------------------
; Oscillator Configuration
;----------------------------------------------------------------
mov OSCXCN, #030h ; External Oscillator Control Register
mov OSCICN, #004h ; Internal Oscillator Control Register
;----------------------------------------------------------------
; Reference Control Register Configuration
;----------------------------------------------------------------
mov REF0CN, #000h ; Reference Control Register
;----------------------------------------------------------------
; SPI Configuration
;----------------------------------------------------------------
mov SPI0CN, #000h ; SPI Control Register
mov SPI0CFG, #000h ; SPI Configuration Register
mov SPI0CKR, #000h ; SPI Clock Rate Register
;----------------------------------------------------------------
; UART Configuration
;----------------------------------------------------------------
mov SCON, #000h ; Serial Port Control Register
mov PCON, #000h ; Power Control Register
;----------------------------------------------------------------
; ADC Configuration
;----------------------------------------------------------------
mov AMX0CF, #060h ; AMUX Configuration Register
mov AMX0SL, #000h ; AMUX Channel Select Register
mov ADC0CF, #000h ; ADC Configuraion Register
mov ADC0CN, #000h ; ADC Control Register
mov ADC0LTH, #000h ; ADC Less-Than High Byte Register
mov ADC0GTH, #0FFh ; ADC Greater-Than High Byte Register
;----------------------------------------------------------------
; Timer Configuration
;----------------------------------------------------------------
mov CKCON, #000h ; Clock Control Register
mov TH0, #000h ; Timer 0 High Byte
mov TL0, #000h ; Timer 0 Low Byte
mov TH1, #000h ; Timer 1 High Byte
mov TL1, #000h ; Timer 1 Low Byte
mov TMOD, #000h ; Timer Mode Register
mov TCON, #000h ; Timer Control Register
mov RCAP2H, #000h ; Timer 2 Capture Register High Byte
mov RCAP2L, #000h ; Timer 2 Capture Register Low Byte
mov TH2, #000h ; Timer 2 High Byte
mov TL2, #000h ; Timer 2 Low Byte
mov T2CON, #000h ; Timer 2 Control Register
---------------------------------------------------------------
; Reset Source Configuration
;
; Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
;------------------------------------------------------------------
; | R | R/W | R/W | R | R | R/W | R
;------------------------------------------------------------------
;Reserved|NOT | Comp.0 | S/W | WDT | Miss. | POR | HW
; |USED | Reset/ | Reset | Reset | Clock | Force | Pin
; | | Enable | Force | Flag | Detect| & | Reset
; | | Flag | & | | Flag | Flag | Flag
; | | | Flag | | |
;------------------------------------------------------------------
;
; NOTE! : Comparator 0 must be enabled before it is enabled as a
; reset source.
;------------------------------------------------------------------
mov RSTSRC, #000h ; Reset Source Register
;----------------------------------------------------------------
; Interrupt Configuration
;----------------------------------------------------------------
mov IE, #000h ;Interrupt Enable
mov IP, #000h ;Interrupt Priority
mov EIE1, #000h ;Extended Interrupt Enable 1
mov EIE2, #000h ;Extended Interrupt Enable 2
mov EIP1, #000h ;Extended Interrupt Priority 1
mov EIP2, #000h ;Extended Interrupt Priority 2
; other initialization code here...
;-----------------------------------------------------------------
; MAIN PROGRAM CODE
;-----------------------------------------------------------------
Main:
; main code routines here...
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -