Initial
This commit is contained in:
55
as68hc11/code/BOOTLOAD.ASM
Normal file
55
as68hc11/code/BOOTLOAD.ASM
Normal file
@@ -0,0 +1,55 @@
|
||||
PORTD equ 08h
|
||||
DDRD equ 09h
|
||||
SPCR equ 28h
|
||||
BAUD equ 2Bh
|
||||
SCCR1 equ 2Ch
|
||||
SCCR2 equ 2Dh
|
||||
SCSR equ 2Eh
|
||||
SCDAT equ 2Fh
|
||||
PPROG equ 3Bh
|
||||
TEST1 equ 3Eh
|
||||
CONFIG equ 3Fh
|
||||
EEPSTR equ 0F800h ; start of EEPROM
|
||||
EEPEND equ 0FFFFh ; end of EEPROM
|
||||
org 0BF40h
|
||||
BEGIN equ *
|
||||
lds 00FFh ; initialize the stack
|
||||
ldx 1000h ; initialize x register for indexed access
|
||||
bset ix,SPCR,20h ; put port D in wire or mode
|
||||
ldaa 0A2h ; initialize SCI & restart baud divider chain
|
||||
staa ix,BAUD
|
||||
ldaa 0Ch ; receiver & transmitter enabled
|
||||
staa ix,SCCR2
|
||||
bset ix,SCCR2,01h ; send break to signal start of download
|
||||
clrbrk:
|
||||
brset ix,PORTD,01h,clrbrk ; clear break as soon as start bit detected
|
||||
bclr ix,SCCR2,01h ; clear break
|
||||
waitchar1:
|
||||
brclr ix,SCSR,20h,waitchar1 ; wait for RDRF
|
||||
ldaa ix,SCDAT ; read data
|
||||
bne NOTZERO ; if data==00h (break or 00) jump to EEPROM
|
||||
jmp EEPSTR ; jump to EEPROM
|
||||
NOTZERO equ *
|
||||
cmpa 055h ; if data==55h skip download (ie) test mode
|
||||
beq STAR
|
||||
cmpa 0FFh ; if data=0FFh then /16 is correct baud rate
|
||||
beq BAUDOK
|
||||
bset ix,BAUD,033h ; otherwise change to /104 (/13 &/8) 1200 @ 2MHZ
|
||||
BAUDOK equ * ; start the download
|
||||
ldy 0000h ; initialize pointer
|
||||
BK2 equ * ; read in program and place in RAM
|
||||
waitchar2:
|
||||
brclr ix,SCSR,20h,waitchar2 ; wait for RDRF
|
||||
ldaa ix,SCDAT ;
|
||||
staa iy,00h
|
||||
staa ix,SCDAT ; handshake
|
||||
iny
|
||||
cpy 0100h
|
||||
bne BK2
|
||||
STAR equ * ; start user program
|
||||
jmp [0000h]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user