Fuse Programming

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Fuse Programming

Post by Sean »

Flowcode for AVR now has the ability to program the device fuse settings from the Chip->Configure menu option.

The following settings will be used as defaults for all devices:
  • 0x0,0xdf
    0x1,0xff
    0x2,0xff
The first value in each pair selects the fuse to be programmed:
  • 0x0 = Fuse High Byte (hfuse)
    0x1 = Fuse Low Byte (lfuse)
    0x2 = Extended Fuse Byte (efuse)
Several of the individual fuse bits have different functions, depending on the device family, so the default settings have been chosen to achieve the following conditions for any device:
  • Select the external high frequency xtal with maximum start-up delay
    Reserve the minimum amount of boot memory
    Enable serial programming (SPIEN)
    Disable all other options (JTAG, Debugging, Watchdog, Brown-out detection, Device emulation, Clock division, EEPROM protection, etc.)
See the 'Memory Programming' section of the device data sheet for specific fuse information.

ATmega168 Examples:
The serial programming enable fuse (SPIEN) is bit 5 of the Fuse High Byte. Setting this bit to zero enables serial programming, resulting in the fuse setting '11011111' = 0xdf (our default value)

The fuse to enable EEPROM saving when the device is erased (EESAVE) is bit 3 of the Fuse High Byte. Enabling this option, by setting the fuse value to zero, would change the data value to '11010111' = 0xd7

Selection of the calibrated internal RC oscillator is achieved by programming the lower 4 bits of the Fuse Low Byte to '0010', resulting in the fuse setting '11110010' = 0xf2

So an ATmega168 running off the internal calibrated RC oscillator, with serial programming enabled, and the EEPROM protected when the device is erased, would have the following fuse settings:
  • 0x0,0xd7
    0x1,0xf2
    0x2,0xff
AVR studio allows individual fuses options to be selected graphically, but the resulting data values transfered to and from the programmer are displayed at the bottom of the control panel when the settings are written or read.

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Just to elaborate on this, the next BETA release will have an "ok & send..." button on the configuration screen, and this will be the only way of sending the fuse data to the AVR. The fuse data will no longer be sent when sending the actual program.

See here for why we have done this:
http://www.matrixmultimedia.com/mmforum ... php?t=4081

I hope to have an updated BETA version ready by the end of today. It will contain:

* an import functionality (allowing the loading of Flowcode programs written for the PICmicro)

* improved interrupt handling, including custom interrupts

* better toolchain access (i.e. gcc and avrdude)

ALAN_26
Posts: 84
Joined: Sat Apr 29, 2006 3:36 pm
Location: MALTA
Contact:

Post by ALAN_26 »


nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Fuse Programming

Post by nils »

Hi

I noticed, that the Atmel Atmega32 that is shipped with the AVR programmer block is not set to the external crystal, but instead to the internal RC clock of 8 MHz. I know this has been resolved by editing the fuse bits, but right now there is no easy way to access these bits inside of Flowcode, or one sticks with a nice script as the reply posted before this one.

But, Flowcode for the AVR assumes as default configuration that the clock is 20 MHz, as well as the delay function. So if one tests these with an oscilloscope and sets a period of e.g 100 ms one ends up with 240 ms. I know that this can be resolved, but wouldn't it be a wiser choice to set the fuse bits to the expected value of 20MHz at the company ? I noticed this on an AVR programmer bought last year in November and the second one was purchased a week or two ago.

It can save some less advanced users the hassle of installing other software or fiddling with the built-in hex code chip settings in Flowcode.
My 2 cents on this, but today I had to help a colleague to get around this problem while working with the PWM timing and he didn't knew how to solve this mystery by himself.

regards,
nils
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Fuse Programming

Post by Sean »

The internal RC oscillator option is the manufacturer's default setting for all devices ( it is guaranteed to be available and allow ISP operation ). Our new factory test routine for the EB019 board now leaves the fitted device configured for the 20MHz external xtal, but any replacement devices would probably be delivered with the original settings.

We will try to increase awareness of the fuse setting issues and provide clear information on how the devices can be configured.

nils
Posts: 33
Joined: Fri Nov 02, 2007 11:03 am
Contact:

Re: Fuse Programming

Post by nils »

I thought about something like manufacture default setting.
It just is only confusing for the first time you notice that a second is not a second and wonder why...

anyway, thanks for clearing that up :)

cheers,
nils
Custom_Code.c help needed? -> http://tinyurl.com/2y2mzq
Flowchart high quality vector graphic output =>>http://tinyurl.com/6sx2sx

Post Reply