I am reading a source code for MC9S08 part of which is supposed to respond to a USB bootloading command (the USB wants to flash new code into the microcontroller). When the MC9S08 is in normal user mode, and if it receives a command Cmd_BootloaderEnable from USB port, it is suppose to go into bootloader mode. The program goes like this (if I read the codes correctly):
1. Upon receiving the command from USB, the MC9S08 will set a variable flag BootloaderEnabled = '1'.
2. It then execute BGND command
3. Since the ENBDM is '0', the instruction BGND is considered illegal and SRS.ILOP will be set to '1'
4. MC9S08 reset
5. On start up, it checks whether BootloaderEnabled == '1', if yes, it jumps to bootloader code
6. USB starts sending bootloading command
Does my intepretation make sense?
- What is the pre-requisite for running bootloader (in order to flash new code to the microcontroller)? Does it have to be in active background mode?
- if ENBDM == '0' and BGND is executed, will the microcontroller reset and then go into active background mode? Or it will just do a NOP? If it does reset, the variable flag BootloaderEnable will be lost, right?