-
Notifications
You must be signed in to change notification settings - Fork 11
Brown Out Detection
The ATTiny (and many other processors) can monitor its power supply voltage to guarantee that the voltage is high enough for correct operation. This can be essential because incorrect operation might not only mean that a calculation yields the wrong result. In the worst case, the EEPROM containing the program itself and the configuration data might be corrupted. This in turn means that the ATTiny no longer works and has to be flashed anew.
The process of monitoring the power supply is called brown-out detection (or BOD for short) and can be enabled by programming specific fuses. If we turn it on and the brown-out detection is triggered, then the processor is put into a reset state until the voltage level is again in the acceptable range.
Brown-out detection is not turned on by default since it needs additional current. This additional current is around 20uA, which is not that much but stops from getting to the lowest possible power consumption modes. This additional current comes from the bandgap reference being active, and since we use the bandgap reference anyway when the processor is active (we are measuring the battery voltage against the bandgap), the actual overhead during the processor activity is negligible.
This additional current can be minimized by turning the brown-out detection off just before going to sleep. It will then be turned on again automatically when waking up, and if the voltage is too low the processor will be stopped at once, just as if brown-out detection hadn’t been turned off at all.
So, we actually can get the best of both worlds, the brown-out detection when the processor is active, and the minimal current consumption when the processor sleeps.
I did quite a few experiments and the best way to disable the brown-out detection was to add a single macro call to one of the libraries that we are using already, sleep_bod_disable()
, that inserts assembler code to disable the brown-out detection just before going to sleep.
To actually burn the fuses follow the instructions in Burning the Fuses.