Post by ddmas on May 1, 2013 9:05:15 GMT
Why we have HCI_RESET COMMAND in Bluetooth?
In Bluetooth Specification there is a command HCI RESET, so most of the time people gets confused why this command is provided or what does this command will do when executed. Well we have a POR (Power on Reset) which will reset the system (Bluetooth device), then why we need a separate command? I had done some analysis on this and I am sharing my findings here, any comments/suggestions are welcome.
In advanced Micro-controllers/processors there are various RESET sources available to reset the System.
1. POR (Power On Reset)
POR is a Master Reset and resets everything!
- Initialize the clock structure or System Clock module
- Initialize all the peripherals (SPI,ADC,PORTS) to known state or default state
- Sets the PC (Program Counter) to ‘Known State’ usually Zero
Normally this procedure is called as a Start-up procedure. Once everything is set the MCU/System is ready to accept/execute any “User Code”.
2. RESET PAD
Usually in all MCU/Processors this PAD is provided to reset the System without “Switching off the Power”. The RESET PAD is connected to RESET pin/switch and by pulling down the pin for specified duration (e.g. 1ms) will RESET the system like POR and it will follow the same sequence as POR.
3. Brown-out Reset
This is used when the voltage supply to the system drops below the permissible level (minimal operating supply voltage). The Brown-out circuitry continuously monitors the supply voltage and if it drops below the defined level it triggers a Reset.
As the micro-controller consists of several circuits which have different operating voltage levels, this can cause it’s out of control performance. In order to prevent it, the micro-controller usually has a circuit for brown out reset built-in. This circuit immediately resets the whole electronics when the voltage level drops below the lower limit.
4. Watch-dog Reset
The watch-dog normally used for observing the system’s normal operation, if the Watch-dog detects the condition like system-hang, it triggers a Reset. Some-times it is used to reset the system after specified duration like the reset occur when the watch-dog timer expires.
One of the most important effects of a reset is setting a program counter (PC) to zero (0000h), which enables the program to start executing from the first written instruction.
5. HCI RESET COMMAND in Bluetooth
Please refer 7.3.2 Reset Command in core_V4.0.pdf for the detailed explanation.
Extract:
- What HCI reset command will do is completely implementation dependent
- It should not interrupt the service provided to other protocol stack
- The reset command will not necessarily perform a hardware reset
- In low energy it will RESET the Link Layer
- Reset command will not reset the HCI transport
- The Host should not send additional HCI commands before the ‘Command Complete Event’ for HCI reset command has been received
So when to use this command? Say I have two scenarios where I can send the HCI RESET command. Normally it will be sent only once during the life-time of application.
1. HOST-CONTROLLER powered by different source
For example I have two separate hardware boards for Host and Controller. The Host controller is powered by USB connected to PC and the Controller is powered by the battery or some other external power supply. I am running my application & stack on Host and it gets POR RESET when I plug the USB to PC.So I can send the HCI reset command to check if I can send more commands to controller for proper functioning of my application, this will ensure the controller is up & ready to accept commands from Host.
2. HOST-Controller powered by same source
For example the Host and Controller are powered by same source and have POR at the same time. But the start-up procedure may take different time in Controller or Host.As per
Specification the controller sends the Command Complete Event when the controller is up (executed the start-up code & ready) normally after POR, but if the host has missed this event code or its corrupted due to the Transport Layer was not initialized or it took long time to initialize the application & stack on Host.
In this case the Host can send the HCI Reset command to ensure that Controller is ready for further communication.
So again what will be reset on this command is implementation dependent! But surely it will not be a hardware reset.
Note: Here Host is referred as any general purpose Micro-controller/processor and Controller means the Bluetooth Controller.
In Bluetooth Specification there is a command HCI RESET, so most of the time people gets confused why this command is provided or what does this command will do when executed. Well we have a POR (Power on Reset) which will reset the system (Bluetooth device), then why we need a separate command? I had done some analysis on this and I am sharing my findings here, any comments/suggestions are welcome.
In advanced Micro-controllers/processors there are various RESET sources available to reset the System.
1. POR (Power On Reset)
POR is a Master Reset and resets everything!
- Initialize the clock structure or System Clock module
- Initialize all the peripherals (SPI,ADC,PORTS) to known state or default state
- Sets the PC (Program Counter) to ‘Known State’ usually Zero
Normally this procedure is called as a Start-up procedure. Once everything is set the MCU/System is ready to accept/execute any “User Code”.
2. RESET PAD
Usually in all MCU/Processors this PAD is provided to reset the System without “Switching off the Power”. The RESET PAD is connected to RESET pin/switch and by pulling down the pin for specified duration (e.g. 1ms) will RESET the system like POR and it will follow the same sequence as POR.
3. Brown-out Reset
This is used when the voltage supply to the system drops below the permissible level (minimal operating supply voltage). The Brown-out circuitry continuously monitors the supply voltage and if it drops below the defined level it triggers a Reset.
As the micro-controller consists of several circuits which have different operating voltage levels, this can cause it’s out of control performance. In order to prevent it, the micro-controller usually has a circuit for brown out reset built-in. This circuit immediately resets the whole electronics when the voltage level drops below the lower limit.
4. Watch-dog Reset
The watch-dog normally used for observing the system’s normal operation, if the Watch-dog detects the condition like system-hang, it triggers a Reset. Some-times it is used to reset the system after specified duration like the reset occur when the watch-dog timer expires.
One of the most important effects of a reset is setting a program counter (PC) to zero (0000h), which enables the program to start executing from the first written instruction.
5. HCI RESET COMMAND in Bluetooth
Please refer 7.3.2 Reset Command in core_V4.0.pdf for the detailed explanation.
Extract:
- What HCI reset command will do is completely implementation dependent
- It should not interrupt the service provided to other protocol stack
- The reset command will not necessarily perform a hardware reset
- In low energy it will RESET the Link Layer
- Reset command will not reset the HCI transport
- The Host should not send additional HCI commands before the ‘Command Complete Event’ for HCI reset command has been received
So when to use this command? Say I have two scenarios where I can send the HCI RESET command. Normally it will be sent only once during the life-time of application.
1. HOST-CONTROLLER powered by different source
For example I have two separate hardware boards for Host and Controller. The Host controller is powered by USB connected to PC and the Controller is powered by the battery or some other external power supply. I am running my application & stack on Host and it gets POR RESET when I plug the USB to PC.So I can send the HCI reset command to check if I can send more commands to controller for proper functioning of my application, this will ensure the controller is up & ready to accept commands from Host.
2. HOST-Controller powered by same source
For example the Host and Controller are powered by same source and have POR at the same time. But the start-up procedure may take different time in Controller or Host.As per
Specification the controller sends the Command Complete Event when the controller is up (executed the start-up code & ready) normally after POR, but if the host has missed this event code or its corrupted due to the Transport Layer was not initialized or it took long time to initialize the application & stack on Host.
In this case the Host can send the HCI Reset command to ensure that Controller is ready for further communication.
So again what will be reset on this command is implementation dependent! But surely it will not be a hardware reset.
Note: Here Host is referred as any general purpose Micro-controller/processor and Controller means the Bluetooth Controller.