?? init_hyperterm.asm
字號(hào):
* Init.asm
**********************************************************************
* Initialize the I/O, ICG, KBD, IRQ *
**********************************************************************
**********************************************************************
* Init_Vars *
* Initialize the RAM variables. *
**********************************************************************
Init_Vars: MOV #$FF,SWITCH ;Default configuration is for FSK.
MOV #$FF,LAST_SWITCH
LDHX #FLASHVARS
MOV X+,THRESHOLD
MOV X+,LFID
MOV X+,LFID+1
MOV X+,LFID+2
MOV X+,LFID+3
MOV X+,RFID
MOV X+,RFID+1
MOV X+,RFID+2
MOV X+,RFID+3
MOV X+,LRID
MOV X+,LRID+1
MOV X+,LRID+2
MOV X+,LRID+3
MOV X+,RRID
MOV X+,RRID+1
MOV X+,RRID+2
MOV X+,RRID+3
CLR LFCNTH ;Clear the timeout counters.
CLR LFCNTL
CLR LRCNTH
CLR LRCNTL
CLR RRCNTH
CLR RRCNTL
CLR RFCNTH
CLR RFCNTL
CLR FAST_MODE
CLR TEMP
CLR TEMPTIME
CLR TEMPTIME+1
CLR TIMESTAMP
RTS
**********************************************************************
* Init_KBD *
* We don't use keyboard or IRQ interrupts in this program. *
**********************************************************************
Init_KBD: BSET 1,KBSCR ;
BSET 1,ISCR ;Mask interrupts
BSET 2,KBSCR ;
BSET 2,ISCR ;Clear any pending interrupt requests
RTS
**********************************************************************
* Init_ICG *
* Initializes the internal clock generator module for the *
* external oscillator. *
* For now, 4.9152MHz crystal yielding 1.2288MHz bus frequency. *
**********************************************************************
Init_ICG: LDA #%00010011 ;Mask for external clock
LOOP_ICG STA ICGCR ;Try to set CS, ECGON and clear ICGON.
CMP ICGCR ;Check to see if ICGCR okay.
BNE LOOP_ICG ;Keep looping until ICG settles.
RTS
**********************************************************************
* Init_Ports *
* Initializes PTA and PTB. *
* PTA[4] = MISO (Input during config mode, unused output in RCV mode)*
* PTA[3] = SCK (Output during config mode, input in RCV mode) *
* PTA[2] = MOSI (Output during config mode, input in RCV mode) *
* PTA[1] = /RST (Output) *
* PTA[0] = "RCV" LED *
* PTB[3:0] = RF, RR, LR, LF LEDs *
**********************************************************************
Init_Ports: MOV #%00000010,PTA ;Keep /RST high
MOV #%00010011,DDRA ;Soft SPI, one LED
CLR PTB ;LEDs off
MOV #%00001111,DDRB ;LEDs
RTS
**********************************************************************
* Init_SCI *
* Initializes the serial communications interface. *
**********************************************************************
Init_SCI: MOV #%01000000,SCC1 ;Enable SCI
MOV #%00001000,SCC2 ;Enable Tx
MOV #%00000011,SCBR ;With a 4.9152MHz XTAL, 9600 bauds.
RTS
**********************************************************************
* Init_TBM *
* Initializes the timebase module. This generates periodic *
* interrupts to control the LED flashing when no data is received *
* from a tire. Vector points to 'TBM_Interrupt.' *
* With 4.9152MHz crystal, interrupts occur every 6.67ms while TBM *
* is enabled. *
**********************************************************************
Init_TBM: BCLR 1,TBCR ;Disable TBM
MOV #%00001110,TBCR ;Select TBM divider and enable TBM
RTS
**********************************************************************
* Init_Timer *
* Initialize the timer module. This is used during the SPI receive *
* routine, to assure that we're receiving an entire data frame. If *
* the timer overflows, an interrupt is triggered which resets the *
* bit and byte counters and goes back to the beginning. *
**********************************************************************
Init_Timer: LDA TSC
MOV #%01110000,TSC ;Get the timer ready, stop the counter.
MOV #$13,TMODH ;Set the modulo registers so that the
MOV #$33,TMODL ;timer will overflow in 1ms.
RTS
**********************************************************************
* Init *
* Initializes the MCU *
**********************************************************************
Init: MOV #%00101000,CONFIG2 ;Enable external oscillator, SCI uses CGMXCLK
MOV #%00011011,CONFIG1 ;Disable COP
JSR Init_Vars ;Initialize RAM variables
BSR Init_Ports ;Initialize I/O
BSR Init_ICG ;Initialize external crystal
BSR Init_KBD ;Initialize keyboard interrupts
BSR Init_Timer ;Initialize the timer
BSR Init_SCI ;Initialize the SCI
BSR Init_TBM ;Initialize the TBM
CLRA
CLRH
CLRX
CLI
RTS
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -