3 Brown-out Detector
For the CPU to successfully decode and execute instructions, the supplied voltage must always stay above the minimum voltage level. This level is defined by the chosen operating frequency. For example, an operating frequency of 10 MHz on the Relevant Devices, an operating voltage of minimum 2.7V, must be supplied. If the voltage drops below this threshold, unexpected behavior of the microcontroller (MCU) might occur. This can include incorrect execution of instructions, corruption of CPU registers, Flash corruption, and unexpected toggling of pins. Also, it can cause logic to latch up, possibly entering into incorrect states.
To avoid the above issues, a Brown-out Detector (BOD) can be used. The Relevant Devices includes an on-board, configurable BOD, which monitors the power supply and compares the voltage with a programmable brown-out threshold level. When the BOD detects that the supply voltage crosses the configured threshold, it will assert the internal Reset. As long as the supply voltage remains below the configured threshold level, the device will be kept in Reset. When the supply voltage is above the threshold level, and normal operation can safely continue, the BOD will deassert the internal Reset, allowing the device to execute instructions.
After a Reset, the BOD settings are loaded from fuses. There are two fuses to control the BOD functionality, which are found in the BOD Configuration (BODCFG) under Fuses in the device data sheet.
The first fuse, ACTIVE, defines the operation mode while in Active or in Idle sleep mode. These bits can not be altered by software.
The second fuse, SLEEP, defines the operation mode while in Standby or Power-down sleep mode. These bits may be altered by software and are under the Configuration Change Protection (CCP).
- Disabled mode - BOD is deactivated
- Enabled mode - means that BOD is continuously active
- Sampled mode - BOD is activated briefly at a given period to check the supply voltage level. Frequency is set to either 125 Hz or 1 kHz in Sample Frequency (BODCFG.SAMPFREQ) fuse
- Enabled with wake-up halted until BOD is ready - BOD is not active during sleep. On wake-up, the code execution is halted until BOD is ready. This ensures the correct supply voltage whenever the code is executed. The wake-up time may be extended.
Sample Frequency (SAMPLEFREQ) and BOD Level (LVL) are also found in BODCFG. These control how the BOD behaves.
BOD Levels
Name | Description |
---|---|
BODLEVEL0 | 1.80V |
BODLEVEL2 | 2.60V |
BODLEVEL7 | 4.30V |
When setting the BOD level, several things come into consideration. As already mentioned, the BOD can protect the system from an unsafe operation. Also, the BOD can be used to ensure voltage levels, e.g., when using the ADC. If the ADC is set to sample using the 4.3V internal reference, and the supply voltage drops below this level, the ADC results will be incorrect.
If the BOD is unused, it will be set to the minimum level to ensure safe operation during an internal Reset and chip erase.