Setting BODEN and BODLEVEL programmatically

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

Hi, I'm working with an ATTINY48 and AVR GCC. I'd like to be able to set the BODEN and BODLEVEL fuses programmatically in case some numpty (possibly me) forgets to burn the fuses during production.

 

I've set up the clock prescaler in the code which so far has been saving me an extra step when programming the devices, but I'm wondering it is possible to configure brown out this way too?

 

Here's the code I use to set the clock divider:

 

CLKPR = (1 << CLKPCE); // enable a change to CLKPR
CLKPR = 0; // set the CLKDIV to 0 - was 0011b = div by 8 taking 8MHz to 1MHz

 

Last Edited: Fri. Jun 10, 2016 - 03:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVRs cannot write their fuses from code (only lockbits) so you have no choice about this - they must be ISPd.

 

(and there is no register setting involved in BOD - it is controlled by the fuses alone - actually I say that but I think that chip has BODS/BODSE in MCUCR but they only come into play when the BODEN fuse is already active).

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

Since I have to use a standalone programmer, I wrote a small C program to append the lines of the desired fuses & locks bytes to the hex file generated by Atmel Studio.

I run it via a batch file (*.bat, located in the solution folder) in which I add the fuses (in hex and as three parameters) after the program name.

Automatically, AS executes this batch file (which has likely other tasks as copying and moving) right after compiling the source; as a post event in project properties.

Last Edited: Fri. Jun 10, 2016 - 05:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the answers, I'll work out a process to ensure the fuses get burned during production.

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

You can >>read<< fuses programmatically, but not write them.  If your production includes a bench test, you could test for and report inappropriate fuse values.

"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]