Enabling BOD fuse?

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

This seems like an obvious question but the search function in the form returns far too many results - I can't figure out how to simple search a topic without the function returning every mention of every word in the search from the entire site.  :(  So I did try to find the answer.

 

Trying to figure out how to enable normal brown out on ATTiny416 using Atmel Studio. I am writing and debugging using the green 'play' button labeled "Start without debugging", so I can't use the normal fuse selection drop downs in the memories programming panel.

 

I want to have it defined in my code somewhere so when programming using that "start without debugging" button, the fuses are programmed correctly.

 

My application sometimes doesn't drop voltage all the way to zero when the board is reset (it is a slave module to another device), so instead of having an external volts monitor reset circuit, I want to use BOD to put the device into reset automatically. I'm running at 5v, 20 MHz, so we need the BOD level to be fairly high so we don't violate the voltage vs clock speed safe envelope.

 

I created a project using Atmel Start. In the BOD section it allows me to only select what happens in sleep, but not a box to just enable the BOD period, or to configure it's program level. (Note, I am NOT interested in the 'early warning' VLM stuff, I just want normal BOD). 

 

This project creates a function called BOD_init(), which includes the following line:

 

ccp_write_io((void *)&(BOD.CTRLA), BOD_SLEEP_ENABLED_gc /* Enabled */);

 

I don't understand all the pointer * and BOD_SLEEP_ENABLED_gc shorthand nonsense that Atmel doesn't actually explain anywhere. I just want to set the fuse / register to a specific value and can't figure how how to syntax that.

 

Looking to section 17.5 in the DS for the part, it looks like I need to set bits 3-2 of BOD.CTRLA (the "active" bits to 0x1 "enabled), then I need to set BOD.CTRLB to the desired BOD level, which will be 4.3v BODLEVEL7 0x7 in this case.

 

These registers seem to be a combination of run-time settable and set by fuse. I want to make sure the device always starts up clean, so I would like to have these set in fuses or whatever is the most stable so it just goes into and out of reset as expected when voltage sags.

 

If someone could show a sample code of how to set this, it would be very much appreciated.

 

Thank you.

 

This topic has a solution.
Last Edited: Sat. Jun 30, 2018 - 03:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Disclaimer: I've not used a T416/816.

 

In the data sheet, Section 6.9 Fuses, it discusses the various Fuses, the Signature Row, and the UserRow.

 

The fuses can be read by the CPU or the UPDI, but can only be programmed or cleared by the UPDI.

 

So, I don't think you can put in your start up code what you want the BOD to be set at.

 

JC 

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

Thanks for the reply. I didn't understand anything you were saying with CPU or UPDI.   :(

 

Is there some way to configure how fuses will be set when clicking the "Start Without Debugging" button? There must be some easy way to do this. ?

 

Thank you.

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

Embed them in the fuse section using the functionality in avr/fuse.h (the avr-libc documentation will describe XMEGA style fuses which is what you want for the tn816).

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

Last Edited: Sat. Jun 30, 2018 - 03:01 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Thank you meolsen but I'm still totally lost.

 

There is no avr folder in my project. (I used the Atmel Start to generate the project).

 

There is what appears to be an external reference to a file called fuse.h in the 'dependencies' directory, but when I open it, the code is massively complicated.

 

Literally all I'm trying to do here is turn on the brown out and set it to 4.5 volts. I don't understand why that is so incredibly hard to do or why the DS doesn't provide a simple example like every other MCU I've ever used.   :(

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you just want to set it, why don't you just set it?
.
Fuses are not set during programming (I.e they persist).
.
Tools/Device Programming/Select tool and Device/Apply/Fuses
.
https://www.microchip.com/webdoc/GUID-ECD8A826-B1DA-44FC-BE0B-5A53418A47BD/GUID-9E0F96FB-D51C-4FFB-8DFD-AA40EB583305.html

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

I didn't realize the fuses were maintained between debug and run sessions. I assumed there were set back to defaults because there appear to be some directives in the various include files that change them (or it looks like it anyway, but again it's pretty complicated not sure exactly what it is doing).

 

Thank you. That seems to have solved this problem.

 

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

You can embed fuse information into the elf file using the avr/fuse header which will then be programmed. However if there are no fuse information in the elf then it is not written.

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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


Hi guys,

 

Sorry to open this thread-up again, but the lack of information about setting the BOD made me end up in this thread.

 

So, I will try to explain the problem as follows...I have an application that runs from Li-ion battery (i.e. 4.2V) MCU: ATtiny214, which is the new X-tiny like mcus. my fuses setting are according to tools--> device programming looks like this:


 

which corresponds to:

ACTIVE = ENWAKE
LVL = BODLEVEL0
SAMPFREQ = 125Hz
SLEEP = ENABLED
FREQSEL = 20MHZ
OSCLOCK = [ ]
CRCSRC = NOCRC
EESAVE = [X]
RSTPINCFG = UPDI
SUT = 64MS
CMPA = [ ]
CMPAEN = [ ]
CMPB = [ ]
CMPBEN = [ ]
CMPC = [ ]
CMPCEN = [ ]
CMPD = [ ]
CMPDEN = [ ]
PERIOD = OFF
WINDOW = OFF

APPEND = 0x00 (valid)
BODCFG = 0x1D (valid)
BOOTEND = 0x00 (valid)
OSCCFG = 0x02 (valid)
SYSCFG0 = 0xF7 (valid)
SYSCFG1 = 0x07 (valid)
TCD0CFG = 0x00 (valid)
WDTCFG = 0x00 (valid)

 

Now having done that, the MCU seems to hang-up when the power source goes low...that is ~2V, this happens when I decrease the power source from 4V down to 1V and then going up again to 3V or 4V, I can only run the application via a normal HW reset (Switch OFF/ON), I was wondering what should I do in this situation ?

 

for my BOD c code, I happen to do the following:

 

int8_t BOD_init()
{
	
    ccp_write_io((void*)&(BOD.CTRLA),BOD_SLEEP_DIS_gc /* Disabled */);
	
    BOD.INTCTRL = 0 << BOD_VLMIE_bp 
			 | BOD_VLMCFG_BELOW_gc; 

	return 0;
}

 

Any help would be appreaciated.

 

@admins: If I should open a new thread under this topic let me know, or feel free to do it...

 

Regards,

Moe

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

Ok, never mind...as a work around I used the WDT and cleared it via software....if chip hangs, then the HW WDT will not be cleared by software and then it will reach the maximum timing...hence resetting the chip.

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

Moe, I think you need a reset supervisor. it will make reset low at a certain voltage and only when the voltage rises above a certain voltage it will trigger a proper reset.

you should select it such that it triggers before the BOD does, or else it might not be helpfull at all.

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

meslomp wrote:

Moe, I think you need a reset supervisor. it will make reset low at a certain voltage and only when the voltage rises above a certain voltage it will trigger a proper reset.

you should select it such that it triggers before the BOD does, or else it might not be helpfull at all.

 

meslomp, thanks for the hint. yep, this should also do the job...I was looking at some parts from digikey, seems reasonable price ~9 cents...