Chapter 6 XGATE (S12XGATEV2)
MC9S12XDP512 Data Sheet, Rev. 2.17
Freescale Semiconductor
291
6.9
Initialization and Application Information
6.9.1
Initialization
The recommended initialization of the XGATE is as follows:
1. Clear the XGE bit to suppress any incoming service requests.
2. Make sure that no thread is running on the XGATE. This can be done in several ways:
a) Poll the XGCHID register until it reads $00. Also poll XGDBG and XGSWEIF to make sure
that the XGATE has not been stopped.
b) Enter Debug Mode by setting the XGDBG bit. Clear the XGCHID register. Clear the XGDBG
bit.
The recommended method is a).
3. Set the XGVBR register to the lowest address of the XGATE vector space.
4. Clear all Channel ID flags.
5. Copy XGATE vectors and code into the RAM.
6. Initialize the S12X_INT module.
7. Enable the XGATE by setting the XGE bit.
The following code example implements the XGATE initialization sequence.
6.9.2
Code Example (Transmit "Hello World!" on SCI)
CPU
;###########################################
;#
SYMBOLS
;###########################################
EQU
$00C8
;SCI register space
EQU
SCI_REGS+$00
;SCI Baud Rate Register
EQU
SCI_REGS+$00
;SCI Baud Rate Register
EQU
SCI_REGS+$03
;SCI Control Register 2
EQU
SCI_REGS+$04
;SCI Status Register 1
EQU
SCI_REGS+$07
;SCI Control Register 2
EQU
$80
;TIE bit mask
EQU
$08
;TE bit mask
EQU
$04
;RE bit mask
EQU
$D6
;SCI vector number
S12X
#
SCI_REGS
SCIBDH
SCIBDL
SCICR2
SCISR1
SCIDRL
TIE
TE
RE
SCI_VEC
INT_REGS
INT_CFADDR
INT_CFDATA
RQST
EQU
INT_REGS+$07
INT_REGS+$08
$80
$0120
;Interrupt Configuration Address Register
;Interrupt Configuration Data Registers
;RQST bit mask
;S12X_INT register space
EQU
EQU
EQU
XGATE_REGS
XGMCTL
XGMCTL_CLEAR
XGMCTL_ENABLE
XGCHID
XGVBR
XGIF
EQU
EQU
EQU
EQU
EQU
EQU
EQU
$0380
XGATE_REGS+$00
$FA02
$8282
XGATE_REGS+$02
XGATE_REGS+$06
XGATE_REGS+$08
;XGATE register space
;XGATE Module Control Register
;Clear all XGMCTL bits
;Enable XGATE
;XGATE Channel ID Register
;XGATE ISP Select Register
;XGATE Interrupt Flag Vector