Chapter 9 XGATE (S12XGATEV2)
MC9S12XDP512 Data Sheet, Rev. 2.11
Freescale Semiconductor 483
XGCHID EQU XGATE_REGS+$02 ;XGATE Channel ID Register
XGVBR EQU XGATE_REGS+$06 ;XGATE Vector Base Register
XGIF EQU XGATE_REGS+$08 ;XGATE Interrupt Flag Vector
XGSWT EQU XGATE_REGS+$18 ;XGATE Software Trigger Register
XGSEM EQU XGATE_REGS+$1A ;XGATE Semaphore Register
RPAGE EQU $0016
RAM_SIZE EQU 20*$400 ;20k RAM
RAM_START_GLOBAL EQU $10_0000-RAM_SIZE
RAM_START_XGATE EQU $1_0000-RAM_SIZE
RAM_START_S12 EQU $1000
RPAGE_VALUE EQU RAM_START_GLOBAL>>12
XGATE_VECTORS EQU RAM_START_S12
XGATE_DATA EQU RAM_START_S12+(4*128)
XGATE_OFFSET EQU (RAM_START_XGATE+(4*128))-XGATE_DATA_BEGIN
BUS_FREQ_HZ EQU 40_000000
;###########################################
;# RESET VECTOR #
;###########################################
ORG $FFFE
DW START_OF_CODE
ORG $3000
START_OF_CODE
;###########################################
;# INITIALIZE SCI #
;###########################################
INIT_SCI MOVW #(BUS_FREQ_HZ/(16*9600)), SCIBDH ;set baud rate
MOVB #(TIE|TE|RE), SCICR2 ;enable tx buffer empty interrupt
;###########################################
;# INITIALIZE S12X_INT #
;###########################################
INIT_INT SEI ;disable interrupts
MOVB #(SCI_VEC&$F0), INT_CFADDR ;switch SCI interrupts to XGATE
MOVB #RQST|$01, INT_CFDATA+((SCI_VEC&$0F)>>1)
;###########################################
;# INITIALIZE XGATE #
;###########################################
INIT_XGATE MOVW #XGMCTL_CLEAR, XGMCTL ;clear all XGMCTL bits
BRSET XGCHID, $FF, INIT_XGATE ;wait until current thread is done
MOVW #$10000-RAM_SIZE, XGVBR ;set vector base register
LDX #XGIF ;clear all channel interrupt flags
LDD #$FFFF
STD 2,X+
STD 2,X+
STD 2,X+
STD 2,X+
STD 2,X+
STD 2,X+