|
自己寫的startup.ASM文件為什么在有了main.c文件之后會失效?取消main.c就又正常了?
;===================================================================================
#define __ASM_CODE__
#include "compile_option.h"
#include "DC_FSB.h"
;#include "variables.inc"
#define SP_START 07h
#define Ram_Start 08h
#define Ram_End 03Fh
NAME SEGMENT_CODE_START_UP ; Specify the name of the current module
USING 0 ; use register bank 0
;===================================================================================
; Constants
;===================================================================================
;===================================================================================
; Variables
;===================================================================================
;#define BF_CHIP_MODE 2fh.3 ; 0 => chip, 1 => DEEMAX emulator (DC6688FSA/DC6688FS Family, Refer AppNote008)
;===================================================================================
; External reference
;===================================================================================
EXTRN CODE (MAIN)
;EXTRN CODE (Delay_100ms)
CSEG AT 0000H ; code segment start at 0000H
USING 0 ; use register bank 0
;--------------------------------------
; Reset Vector 000h :
;--------------------------------------
ORG 0h
ljmp START_UP
;--------------------------------------
; user program is started here
;compile_option.h
;--------------------------------------
ORG 80h
public START_UP
START_UP:
#ifdef __DEBUG_MODE__
mov 0A0h, #0
#endif
;---------------------------------------------------
; select band 0 registers
;---------------------------------------------------
clr RS0
clr RS1
; ---------------------------------------------------
; OFF_ LED 1st
; ---------------------------------------------------
; lcall Delay_100ms
MOV R0, #xPCCONL ;00 10 00 11
MOV A, #00100011B ;PCCONL[1,0] 11 = counter A output
MOVX @R0,A ;10 push pull O/P (PC1)
;00 input interrupt on falling edge (PC2, PC0)
MOV R0, #xPORT_C
MOV A, #00000000B ;0x00
MOVX @R0,A
;---------------------------------------------------
; clear DPS_0 to make use of DPTR
;---------------------------------------------------
; mEnable_DPTR_0 ;DPS
;;---------------------------------------------------
;; disable all interrupt and clear all IRQ
;;---------------------------------------------------
mov IE, #0
; disable counter A interrupt
mov TCON, #0 ; clear Port A, Counter A, Timer 0, Timer 1 IRQ
mov T2CON, #0 ; clear Timer 2 IRQ and reset timer config
mov SCON0, #0 ; clear Serial 0 IRQ and reset serial control 0 config
mov SCON1, #0 ; clear Serial 1 IRQ and reset serial control 1 config
mov IP, #0 ; all interupt in low priority
;---------------------------------------------------
; Start + test
;---------------------------------------------------
MOV A,#0 ; MATTHEW
SETB ET2 ; Timer 2 overflow interrupt
CLR IT0 ; falling edge trigger
; SETB EA
CLR EX0
;;---------------------------------------------------
;; disable watchdog
;;---------------------------------------------------
MOV R0, #xBTCON
MOV A, #0xA8
MOVX @R0,A
;---------------------------------------------------
; clear internal RAM
;
; note :
; - clear all direct accessable RAM from 00h
; - clear indirect RAM up to stack area
;---------------------------------------------------
mov a, #Ram_Start ;08h
mov R0, a
clear_all_int_ram_loop:
mov a, #000h
mov @R0, a
inc R0
cjne R0, #Ram_End ,clear_all_int_ram_loop
init_SP:
;---------------------------------------------------
; init Stack pointer
; note :
; - pre-incremented stack
; - because of software stack, it is better to
; init Stack pointer after clear RAM
;---------------------------------------------------
;mov SP, #(LOW (RI_STACK-1)) ; '-1' because of pre-increment
mov SP, #SP_START ;
;all interrupts in low priority
mov IP, #0
;clear IT0 for proper Port A interrupt function
clr IT0
MOV R0, #xPCCONL ;00 10 00 11
MOV A, #00100011B ;PCCONL[1,0] 11 = counter A output
MOVX @R0,A ;10 push pull O/P (PC1)
;00 input interrupt on falling edge (PC2, PC0)
MOV R0, #xPORT_C ; PC[2] = INPUT MODE, INTERRUPT ON RISING
MOV A, #00000000B ; 0x00 ; PC[1] = push pull output (IR)
MOVX @R0,A ; PC[0] = push pull output (LED)
CLR EX0
; sjmp $
ljmp main
; =====================================================
; =====================================================
; =====================================================
/*
ISR_PORT_BC:
;ISR_PORT_A:
CLR GF_SLEEP0
MOV R0,#xPAPND
MOV A,#0
MOVX @R0,A
; MOV R0,#xPCPND
; MOV A,#0
; MOVX @R0,A
; CLR IE0 ;CLR PORTB, C INTERRUPT FLAG
CLR EX0 ;PortB, C ext interrupt
CLR IT0
NOP
RETI
*/
; =====================================================
; =====================================================
; =====================================================
/*
ISR_TIMER_2:
CLR TF2
RETI
*/
; =====================================================
; =====================================================
#undef __ASM_CODE__
end |
|