bootloader: reset X before wait
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
;; M Code
|
;; M Code
|
||||||
;; option O0 O1 N1 O2 N2 O3 N3 O4 N4 O5 N5
|
;; option O0 O1 N1 O2 N2 O3 N3 O4 N4 O5 N5
|
||||||
;; 4800 00 00 FF 00 FF 00 FF 00 FF 00 FF -- -- -- -- --
|
;; 4800 00 00 ff 00 ff 00 ff 00 ff 00 ff -- -- -- -- --
|
||||||
;; 03D0|4810 -- -- -- -- -- -- -- -- -- -- -- -- 00 03 DF A6
|
;; 03D0|4810 -- -- -- -- -- -- -- -- -- -- -- -- 00 03 df a6
|
||||||
;; 03E0|4820 0D C7 52 32 C7 52 35 C7 52 31 5C 27 0D 72 0B 52
|
;; 03E0|4820 0d c7 52 32 c7 52 35 c7 52 31 5f 5c 27 0c 72 0b
|
||||||
;; 03F0|4830 30 F8 3B 52 31 5F 4C 26 F1 81 72 CC 48 3E 80 04
|
;; 03F0|4830 52 30 f8 3b 52 31 4c 26 f1 81 72 cc 48 3e 80 04
|
||||||
|
|
||||||
;; UART1 register address definitions (STM8S103F3)
|
;; UART1 register address definitions
|
||||||
UART1_SR = 0x5230 ; Status register
|
UART1_SR = 0x5230 ; Status register
|
||||||
UART1_DR = 0x5231 ; Data register
|
UART1_DR = 0x5231 ; Data register
|
||||||
UART1_BRR1 = 0x5232 ; Baud rate register 1
|
UART1_BRR1 = 0x5232 ; Baud rate register 1
|
||||||
UART1_CR2 = 0x5235 ; Control register 2
|
UART1_CR2 = 0x5235 ; Control register 2
|
||||||
|
|
||||||
RAM_SIZE = 0x0400 ; Ram size (end of address)
|
RAM_SIZE = 0x0400 ; Ram size (end of address)
|
||||||
|
|
||||||
;; Bootloader body (located in OPT reserved area 0x481C-0x483F)
|
;; Bootloader body (located in OPT reserved area 0x481C-0x483F)
|
||||||
@@ -34,15 +35,16 @@ _bootO_start:
|
|||||||
|
|
||||||
;; Receive maximum 243-byte data block and push onto stack
|
;; Receive maximum 243-byte data block and push onto stack
|
||||||
_bootO_rx_byte:
|
_bootO_rx_byte:
|
||||||
|
clrw X ; [5F] Reset X (for timeout detection)
|
||||||
|
_bootO_rx_wait:
|
||||||
incw X ; [5C] Increment X, check for overflow (timeout detection)
|
incw X ; [5C] Increment X, check for overflow (timeout detection)
|
||||||
jreq _bootO_exit ; [27 0D] If X overflows (receive timeout), exit
|
jreq _bootO_exit ; [27 0C] If X overflows (receive timeout), exit
|
||||||
|
|
||||||
;; Wait for data reception
|
;; Wait for data reception
|
||||||
btjf UART1_SR, #5, _bootO_rx_byte ;[72 0B 52 30 F8]
|
btjf UART1_SR, #5, _bootO_rx_wait;[72 0B 52 30 F8]
|
||||||
|
|
||||||
;; Data received, push onto stack
|
;; Data received, push onto stack
|
||||||
push UART1_DR ; [3B 52 31]
|
push UART1_DR ; [3B 52 31]
|
||||||
clrw X ; [5F] Reset X (for timeout detection)
|
|
||||||
inc A ; [4C] Increment A, used as receive counter
|
inc A ; [4C] Increment A, used as receive counter
|
||||||
jrne _bootO_rx_byte ; [26 F1] If A is not 0, continue receiving
|
jrne _bootO_rx_byte ; [26 F1] If A is not 0, continue receiving
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user