📄 s12sermon2r1.lst
字号:
672 159 0000 0007 UPc: equ 7 ;user's PC
673 160 0000 0009 SPOffset: equ 9 ;offset of stack pointer while in monitor
674 161
675 162 0000 0023 MaxMonStack equ 35 ;maximum number of bytes used by Monitor
676 163 0000 101A LowSPLimit equ RamStart+MaxMonStack-SPOffset
677 164 0000 3FF7 HighSPLimit equ RamLast-SPOffset+1
678 165
679 166 ; named locations on stack if SWI with bad SP value
680 167 ;*********************************************************************
681 168 ;* Start of code and/or constant data
682 169 ;*********************************************************************
683 170 org BootStart ;beginning of protected flash
684 171 ;*********************************************************************
685 172 ;* Main startup program - real reset vector points to here
686 173 ;*********************************************************************
687 174 ;*********************************************************************
688 175 ; THIS LOCKS RAM / REGS / AND EEPROM BY USING ONLY WRITE USER CODE
689 176 ; WILL NOT EFFECT THESE SETTINGS...This is for derivative compatibility
690 177 ; Please refer to EB388
691 178 ;*********************************************************************
692 179 ColdStart:
693 180 Startup:
694 181 main:
695 182 a00F800 180B 0000 movb #$00,INITRG ;set registers at $0000
00F804 11
696 183 a00F805 180B 3900 movb #$39,INITRM ;set ram to end at $3fff
00F809 10
697 184 a00F80A 4F1C 3005 brclr MEMSIZ0,eep_sw1+eep_sw0,ColdStart1 ;Check if device has EEprom
698 185 a00F80E 180B 0900 movb #$09,INITEE ;set eeprom to end at $0fff
00F812 12
699 186
700 187 a00F813 87 ColdStart1: clra ;A=0=cold start; see tsta @ ChkCold
701 188
702 189 ;**********************************************************************
703 190 ; Decide whether to go to user reset or bootloader/monitor
704 191 ;**********************************************************************
705 192 ; (a) default to monitor if high byte user pseudo-vector is erased ($FF)
706 193 ;**********************************************************************
Metrowerks HC12-Assembler
(c) COPYRIGHT METROWERKS 1987-2003
Abs. Rel. Loc Obj. code Source line
---- ---- ------ --------- -----------
707 194 a00F814 F6F7 FE ldab vector00-($10000-BootStart) ;check for user reset Vector
708 195 a00F817 51 comb ;if erased COMB result will be 0
709 196 a00F818 2726 beq Monitor ;default to monitor if no vector
710 197
711 198 ;**********************************************************************
712 199 ; Test the state of some pins to force entering the monitor
713 200 ; Depending on the hardware configuration enable/disable/modify the
714 201 ; sections below
715 202 ;**********************************************************************
716 203 a00F81A 4C0C 01 bset SwPullup,mSwPullup ;enable pullup on force monitor sw
717 204 a00F81D 1C02 4D01 bset PPSS,PPSS0 ;enable pullup on RxD0 pin
718 205 a00F821 1C02 4C01 bset PERS,PERS0 ;on RxD0 pin
719 206 a00F825 C7 clrb
720 207 a00F826 0431 FD dbne b,* ;delay to allow sw pin to pull up
721 208 ;**********************************************************************
722 209 ; (b) force monitor if SwPort bit SWITCH = 0
723 210 ; Note: this port is configured after reset as input with pull-up
724 211 ; With no connection to this pin the monitor jumps to run mode
725 212 ;**********************************************************************
726 213 a00F829 D600 ldab SwPort ;get port value
727 214 a00F82B C540 bitb #Switch ;test the sw bit
728 215 a00F82D 2711 beq Monitor
729 216
730 217 ;**********************************************************************
731 218 ; (c) force monitor if RxD low (from host) PORTS bit 0
732 219 ; This is true if the host holds RxD on break level
733 220 ; Note: this port is configured after reset as input with pull-up
734 221 ;**********************************************************************
735 222 a00F82F 1F02 4801 brclr PTS,PTS0,Monitor ;to monitor if RxD low
00F833 0C
736 223 a00F834 1D02 4D01 bclr PPSS,PPSS0 ;restore reset state on RxD0 pin
737 224 a00F838 1D02 4C01 bclr PERS,PERS0 ;restore reset state on RxD1 pin
738 225
739 226 ;**********************************************************************
740 227 ; finally jump to the user application (by pseudo vector)
741 228 ;**********************************************************************
742 229 a00F83C 05FB xxxx jmp [vector00-($10000-BootStart),pcr] ;go where
743 230 ;user reset vector points
744 231 ;*********************************************************************
745 232 ; Formal start of Monitor code
746 233 ;*********************************************************************
747 234 Monitor:
748 235 ; Initialize clock generator and PLL
749 236 ;
750 237 a00F840 4D0C 01 bclr SwPullup,mSwPullup ;restore reset state
751 238 a00F843 4D39 80 bclr CLKSEL,PLLSEL ;disengage PLL to system
752 239 a00F846 4C3A 40 bset PLLCTL,PLLON ;turn on PLL
753 240 a00F849 180B 0200 movb #initSYNR,SYNR ;set PLL multiplier
00F84D 34
754 241 a00F84E 180B 0000 movb #initREFDV,REFDV ;set PLL divider
00F852 35
755 242 a00F853 A7 nop
756 243 a00F854 A7 nop
757 244 a00F855 4F37 08FC brclr CRGFLG,LOCK,*+0 ;while (!(crg.crgflg.bit.lock==1))
758 245 a00F859 4C39 80 bset CLKSEL,PLLSEL ;engage PLL to system
759 246 ;
760 247 ; set flash/EEPROM clock to 200 kHz
761 248 ;
762 249 0000 0000 IF OscFreq >= 12800
765 252 ELSE
766 253 a00F85C 180B 2701 movb #((OscFreq/200)-1),FCLKDIV ;Flash CLK = 200 kHz
00F860 00
767 254 a00F861 180B 2701 movb #((OscFreq/200)-1),ECLKDIV ;Eeprom CLK = 200 kHz
00F865 10
Metrowerks HC12-Assembler
(c) COPYRIGHT METROWERKS 1987-2003
Abs. Rel. Loc Obj. code Source line
---- ---- ------ --------- -----------
768 255 ENDIF
769 256 ;
770 257 ; Set stack pointer to last (highest) RAM location
771 258 ;
772 259 a00F866 CF40 00 stackInit: lds #RamLast+1 ;point one past RAM
773 260
774 261 ; Setup initial user CPU register values (user register stack frame)
775 262 ; A holds the initial state value
776 263 a00F869 FEF7 FE initUregs: ldx BootStart-2 ;load user reset vector
777 264 a00F86C 34 pshx ;$00 to user UPc $3FFe
778 265 a00F86D CE00 00 ldx #$0000
779 266 a00F870 34 pshx ;$00 to user UYreg $3ffc
780 267 a00F871 34 pshx ;$00 to user UXreg $3ffa
781 268 a00F872 34 pshx ;$00 to user UDreg $3ff8
782 269 a00F873 C6D0 ldab #initUCcr ;initial value for user CCR
783 270 a00F875 37 pshb ;to UCcr $3ff7
784 271
785 272 ;
786 273 ; set baud rate to 115.2 kbaud and turn on Rx and Tx
787 274 ;
788 275 a00F876 180B 0D00 movb #baud115200,SCI0BDL ;..BDH=0 so baud = 115.2 K
00F87A C9
789 276 a00F87B 180B 0C00 movb #initSCI0CR2,SCI0CR2 ;Rx and Tx on
00F87F CB
790 277 ;
791 278 ; if warm start, skip break. A is a flag to indicate cold vs warm start.
792 279 ; Avoid using A above here *****
793 280 ;
794 281 a00F880 97 ChkCold: tsta ;0=cold start, non-zero=warm start
795 282 a00F881 2709 beq coldBrk ;if cold send break
796 283 ;
797 284 ; Send a warm start prompt and wait for new commands
798 285 ;
799 286 a00F883 86E3 ldaa #ErrSP ;error code for bad SP
800 287 a00F885 16FC 85 jsr PutChar ;send error code (1st prompt char)
801 288 a00F888 860C ldaa #StatWarm ;status code for warm start
802 289 a00F88A 202F bra EndPrompt ;finish warm start prompt
803 290 ;
804 291 ; Cold start so Generate long break to host
805 292 ;
806 293 a00F88C 4FCC 80FC coldBrk: brclr SCI0SR1,TDRE,* ;wait for Tx (preamble) empty
807 294 a00F890 4CCB 01 bset SCI0CR2,SBK ;start sending break after preamble
808 295 a00F893 CE05 DC ldx #longBreak ;at least 30 bit times for Windows
809 296 a00F896 8E00 00 BrkLoop: cpx #0 ;[2]done?
810 297 a00F899 0435 FA dbne x,BrkLoop ;[3]
811 298 a00F89C 4DCB 01 bclr SCI0CR2,SBK ;stop sending breaks
812 299
813 300 a00F89F 16FC 7C waitforCR: jsr GetChar ;should be asciiCR or $00 with FE=1
814 301 a00F8A2 810D cmpa #asciiCR ;.eq. if 115.2K baud OK
815 302 a00F8A4 26F9 bne waitforCR
816 303
817 304 ;*********************************************************************
818 305 ;* end of reset initialization, begin body of program
819 306 ;*********************************************************************
820 307 ;
821 308 ; Send a cold start prompt and wait for new commands
822 309 ;
823 310 a00F8A6 86E0 ldaa #ErrNone ;code for no errors ($E0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -