![Pololu P-Star 25K50 Micro User Manual Download Page 27](http://html1.mh-extra.com/html/pololu/p-star-25k50-micro/p-star-25k50-micro_user-manual_1574946027.webp)
time to detect that the application has disconnected.
The code below is PIC assembly code that shows how these vectors are defined in the bootloader.
The two CPU interrupt vectors (0x0008 and 0x0018) each have a
goto
instruction that jumps directly
to the user application. The two entry vectors (0x0000 and 0x0004) each have
goto
instructions that
jump to the appropriate part of the bootloader code.
Serial number
The bootloader comes with a unique serial number that is assigned during manufacturing. This serial
number is typically an 8-digit decimal number, but in the future we might expand it to have other
characters or make it be up to 16 characters long. The serial number is accessible from the application,
and applications using USB can expose the serial number as a string descriptor.
Read-only data
Part of the bootloader’s flash memory is used to store some information that can be read by the
application:
• Addresses 0x40–0x51 contain the USB device descriptor of the bootloader, as defined in the
USB 2.0 Specification.
• Addresses 0x60–0x70 contain the serial number as an ASCII string with a null terminator
byte. The extra bytes after the null terminator are all set to zero.
• Addresses 0x80–0xA1 contain the serial number in USB string descriptor format. The extra
bytes after the end of the string are all set to zero.
6.2. Startup procedure
Every time the microcontroller powers on or is reset for any reason, the bootloader’s startup code runs.
First, the code sets all of the bytes in RAM to 0, which can help make the behavior of the bootloader
and the application more predictable. Second, it reads the first word of the application’s flash section.
If that word is 0xFFFF, it considers the application to be missing and it runs the bootloader. Third, it
reads pin RB6 and runs the bootloader if RB6 is high. Finally, if none of these tests have caused it to
go into bootloader mode, it runs the application.
1
2
3
4
5
6
7
8
9
10
11
org
0x0000
; CPU reset vector
goto
powerup
; Start app or bootloader
org
0x0004
; Bootloader launch vector
goto
powerupBootloader
; Start bootloader
org
0x0008
; CPU high-priority interrupt vector
goto
0x2008
; Jump to the application's ISR
org
0x0018
; CPU low-priority interrupt vector
goto
0x2018
; Jump to the application's ISR
Pololu P-Star User’s Guide
© 2001–2019 Pololu Corporation
6. The P-Star Bootloader
Page 27 of 46