Brown-out Detection (BOD) notification for the AVR

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi all,

I am using an ATTINY24V-10PU running at 1Mhz (default) with a 3V battery power supply--2xAAA cells. I would like to experiment with brown-out detection (BOD), thus, programmed the fuse-bits to have BOD in effect at 1.8V. BOD circuitry is probably the same for all Atmel AVR chips, e.g., same for ATMEGA series, etc.

Ok, my question is: Is there a way AVR would notify you when the BOD has occurred? This way, at least, I can flash a red LED to tell the user that the gadget is running low on battery. It seems like the key is the RESET functionality (vector) kicks in when a BOD happens. So, do I need to write a routine to have the RESET vector point to my routine and do the LED thing? Then do a RESET? Thanks.

So far I have read the below tidbits in the spec.:


Keep the AVR RESET active (low) during periods of insufficient power supply voltage. This can
be done by enabling the internal Brown-out Detector (BOD). 
...
When the Brown-out Detector (BOD) is enabled by BODLEVEL fuses (see Table 19-4 on page
160), the BOD is actively monitoring the supply voltage during a sleep period. In some devices it
is possible to save power by disabling the BOD by software in Power-Down and Stand-By sleep
modes. The sleep mode power consumption will then be at the same level as when BOD is globally
disabled by fuses.
Last Edited: Sat. Mar 18, 2017 - 12:35 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

unebonnevie wrote:
Is there a way AVR would notify you when the BOD has occurred?
In general, when a brownout occurs, your device will be reset. When your code begins running again, the reset flags will indicate that a brownout reset occurred.

The purpose of the brownout detector is to prevent the device from operating when the supply voltage is too low to operate reliably. If you want to notify a user that the battery level is low, you'll need to add a voltage monitor and start signaling at a voltage level higher than the brownout threshold.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is something that you can use the comparator for.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From the Mega128 data sheet...
The MCU Control and Status Register provides information on which reset source caused an
MCU reset.
Note that only EXTRF and PORF are available in ATmega103 compatibility mode.
• Bit 4 – JTRF: JTAG Reset Flag
This bit is set if a reset is being caused by a logic one in the JTAG Reset Register selected by
the JTAG instruction AVR_RESET. This bit is reset by a Power-on Reset, or by writing a logic
zero to the flag.
• Bit 3 – WDRF: Watchdog Reset Flag
This bit is set if a Watchdog Reset occurs. The bit is reset by a Power-on Reset, or by writing a
logic zero to the flag.
• Bit 2 – BORF: Brown-out Reset Flag
This bit is set if a Brown-out Reset occurs. The bit is reset by a Power-on Reset, or by writing a
logic zero to the flag.

The problem appears to be that if you have a power on reset follow then the bit will be cleared.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
In general, when a brownout occurs, your device will be reset. When your code begins running again, the reset flags will indicate that a brownout reset occurred.

Thanks, all. The above is great! All I have to do is putting some code in my main() to do a check on the flags before anything is to be run.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The problem appears to be that if you have a power on reset follow then the bit will be cleared.

I wouldn't call that a "problem", as whenever you turn the power off to an AVR and the BOD is enabled, you will get a BOD trip first as the supply voltage drops. Then, if it continues low enough as with a full power-off you get the power-on reset.

I suppose they could allow both bits to be set and then you'd look for the combination(s). In practice I've never seen it as a problem. In operation with a power-supply circuit with regulator and such, "spurious" BODs without a power-on reset are often/usually an indication of a hard short in an output circuit somewhere--once the AVR BOD trips, the AVR's output is released, the external short is no longer driven, and the power supply recovers.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I wouldn't call that a "problem", as whenever you turn the power off to an AVR and the BOD is enabled, you will get a BOD trip first as the supply voltage drops. Then, if it continues low enough as with a full power-off you get the power-on reset.

That was my point.. that it would likely clear the BOD bit with a reset. The OP was hoping to flash an LED in the case of a BOD. I doubt there would be enough reliable operation time to do that and of course to also power that Red LED he mentioned.

As Jim suggested, it probably is a job for some external circuitry.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
As Jim suggested, it probably is a job for some external circuitry.

Reading AVR180 app notes now. :-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The functions used to write and read data and of course include eeprom in the preprocessor are as in the photos. Hope they are clear.

Attachment(s): 

Crazy generation

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your float values in EEPROM overlap each other. No wonder your data get corrupted.

 

BTW: You posted into the wrong thread.

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've never understood the penchant for absolute addressing in EEPROMs. You don't do it in RAM - you let the linker place your RAM located variables so why don't you do the same for your EEPROM located variables?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just help Anyway,Sternst .

Crazy generation

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your float values in EEPROM overlap each other. No wonder your data get corrupted.

This.

 

BTW: You posted into the wrong thread.

Indeed.  Why has this one been abandonned?:

https://www.avrfreaks.net/forum/eeprom-corrupted

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WHY WAS IT NECESSARY TO DIG UP A 7 YEAR OLD CORPSE?

 

Locked.

 

Ross McKenzie ValuSoft Melbourne Australia

Topic locked