NAME SEGMENT_CODE_START_UP ; Specify the name of the current module
USING 0 ; use register bank 0
;===================================================================================
; Constants
;===================================================================================
;---------------------------------------------------
; 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
;---------------------------------------------------
; 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