
The bootstrap loader
UM0404
DocID13284 Rev 2
This second level of loaded code may be the final application code. It may also be another,
more sophisticated, loader routine that adds a transmission protocol to enhance the integrity
of the loaded code or data. It may also contain a code sequence to change the system
configuration and enable the bus interface to store the received data into external memory.
This process may go through several iterations or may directly execute the final application.
In all cases the ST10F276 will still run in BSL mode, that is, with the watchdog timer
disabled and limited access to the internal Flash area. All code fetches from the internal
Flash area (01’0000
H
...08’FFFF
H
) are redirected to the special Test-Flash. Data read
operations will access the internal Flash of the ST10F276, if any is available, but will return
undefined data on ROM-less devices.
15.4.5
Choosing the baudrate for the BSL via CAN
The Bootstrap via CAN acts in the same way than the UART bootstrap mode. When the
ST10F276 is started in BSL mode, it polls the RxD0 and CAN1_RxD lines. On polling a low
level on one of these lines, a timer is launched that will be stopped when the line gets back
to high level.
For CAN communication, the algorithm is made to receive a zero frame, i-e standard
identifier is 0x0, DLC is 0. This frame will produce on the network the following levels: 5D,
1R, 5D, 1R, 5D, 1R, 5D, 1R, 5D, 1R, 4D, 1R, 1D, 11R. The algorithm will let run the timer
until the detection of the 5th recessive bit. This way the bit timing is calculated over the
duration of 29 bit time: this is done in order to minimize the error introduced by the polling
.
Figure 131. Bitrate measurement over a predefined zero-frame
Error induced by the polling
The code used for the polling is the following:
WaitCom:
JNB
P4.5,CAN_Boot
; if SOF detected on CAN, then go to CAN
; loader
JB
P3.11,WaitCom
; Wait for start bit at RxD0
BSET
T6R
; Start Timer T6
....
CAN_Boot:
BSET
PWMCON0.0
; Start PWM Timer0
; (resolution is 1 CPU clk cycle)
JMPR
cc_UC,WaitRecessiveBit
WaitDominantBit:
JB
P4.5,WaitDominantBit
; wait for end of stuff bit
WaitRecessiveBit:
JNB
P4.5,WaitRecessiveBit; wait for 1st dominant bit = Stuff bit
CMPI1 R1,#5
; Test if 5th stuff bit detected
JMPR
cc_NE,WaitDominantBit
; No, go back to count more
BCLR
PWMCON.0
; Stop timer
; here the 5th stuff bit is detected:
; PT0 = 29 Bit_Time (25D and 4R)
........
Start
Stuff bit
Stuff bit
Stuff bit
Stuff bit
Measured Time