[SOLVED] avr clock fuse problem

Status
Not open for further replies.

bmandl

Full Member level 4
Joined
Feb 26, 2010
Messages
210
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Slovenia
bmandl.edaboard.eu
Activity points
3,006
Hello,
I built my custom atmega644 board with arduino code. I used Sanguino board configuration. My application is using stepper motor. I couldn't figure out, why my stepper is not turning with speed I configure it (at first I thought, that I made a mistake with my custom stepper driver, but it was not the case). Then I somehow noticed, that program is not using proper delays. I figured out, that something is wrong with clock. I have 16Mhz crystal soldered with atmega, but somehow fuses wasn't correctly programmed (i guess). So I decided to program them myself. I burned 0x77 as a low fuse byte and 0x99 as a high fuse byte, which means external full swing oscillator, right? Now, I can't program my avr anymore.
My question is, did I correctly program the fuses for external 16Mhz crystal? And how can I program my avr again? I am using avr pocket programmer from SparkFun.
PS.: When I first programmed my avr, I didn't have crystal soldered yet. Maybe this was the first issue?
Please, don't suggest me to use any hardware programmers to reset fuses (dragon, stk500 or something like that), because I don't have it and I don't have time to order it either.
 

You can use this to check https://www.engbedded.com/fusecalc
The setting seems fine to me.

Do you have the crystal and the two capacitors (12-22pf) in place?

- - - Updated - - -

Note that you have CLKDIV8 enabled so unless you change that in your code your clock will be 16MHz/8=2MHz
 

I used exactly this calculator for my fuses. I have two 18pf capacitors with crystal. So I programed my avr for 2Mhz clock. Now I have to use 2Mhz crystal to program it back to 16Mhz?
But I still don't understand, what was wrong in the first place with timings. If I build my standalone arduino board, I must always program fuses myself?
 

You programmed your device to use a crystal and since you are using a 16MHz crystal the oscillator works at 16MHz.

The clock divider is a feature to control the clock at runtime, it can either be enabled/disabled with the CLKDIV8 fuse or using code in your app.

I think Arduino has the divider fuse disabled by default, so having it enabled means that the serial speed is divided by 8 and the bootloader can't work correctly (I assume you are trying to program the device using the bootloader).

Try to program the device using 0xF7 for the low fuse byte (divider disabled)

- - - Updated - - -

I've downloaded sanguino and checked the boards.txt file.

Code:
atmega644.name=Sanguino W/ ATmega644P

atmega644.upload.protocol=stk500
atmega644.upload.maximum_size=63488
atmega644.upload.speed=57600

atmega644.bootloader.[B][COLOR="#FF0000"]low_fuses=0xFF[/COLOR][/B]
atmega644.bootloader.[B][COLOR="#FF0000"]high_fuses=0x9A[/COLOR][/B]
atmega644.bootloader.extended_fuses=0xFF
atmega644.bootloader.path=atmega
atmega644.bootloader.file=ATmegaBOOT_168_atmega644p.hex
#atmega644.bootloader.file=ATmegaBOOT_644P.hex
atmega644.bootloader.unlock_bits=0x3F
atmega644.bootloader.lock_bits=0x0F

atmega644.build.mcu=atmega644p
atmega644.build.f_cpu=16000000L
atmega644.build.core=arduino
atmega644.build.variant=standard

According to that the fuses you should be using are low byte 0xFF and high byte 0x9A
 

I am not using bootloader. I am programming my avr with avr pocket programmer as I said (as "USBTinyISP in Arduino environment). The problem is, I can't program or read my avr anymore. I get rc error.
 

The only case I've seen ISP programmers fail is if they use a high SCK frequency since the ISP clock should always be much lower than the AVR clock (which is 2MHz in this case).

I have no idea what clock frequency arduino tries to use with usbtiny. There is a -B option for avrdude described .
 

I desoldered crystal and connected external 1Mhz source to XTAL1 (which I made with arduino mega board). I managed to reprogram fuses with -B 250 argument. Then I soldered my crystal back and programmed avr again and timing was correct. But then, I tryed to program fuses to default values again and now I can't program it even with external 1Mhz source anymore. It should work with 16Mhz crystal, with fuses I programmed, but it does not. What could be wrong now?
 

Have you checked the CL value for your crystal? It should be in the datasheet for the crystal.
When you know this, you can calculate the correct values of the load capacitors for the crystal.

You should solder the crystals with care, they can be fragile.
Did you take care to not expose the oscillator terminals for static elctricity, when soldering the crystal?
 

I don't think any of this is the issue, due to the fact, that it worked before I reprogrammed fuses again...
 


What were the default values you have used the last time?
 

I tested crystal and it's fault. Damn, this things are sensitive (I meassured it with x10 probe on osciloscope and I get nothing. I measured another one on my arduino board, there I get 16Mhz sinus signal). I will try to replace it if I find one home and report. In the meantime, can I use some other clock source? For example, it is possible to output 16Mhz on arduino pin (Arduino mega 2560)?

- - - Updated - - -

Crystal is not dead. I tested it on another mcu. It looks like it gets loaded on my board and I don't know why. I tryed several crystals, all apear dead on my board, but working with other mcus (I watched signal on oscilloscope). I really hope, that my mcu is not dead. Its qfn case and I really dont want to desolder it now.

- - - Updated - - -

What could be reason, that I don't see any signal on oscilloscope, when crystal is soldered on my board, but I can see the signal, if it's connected on another MCU? It worked before, so connections are ok. I doubt, that MCU is dead, there really isn't anything that could possibly burned it. :-(
 

Now I made my problem even worse :-x I figured, I will try to use my arduino mega2560 clkout pin to generate 16Mhz square wave and try feed that to my board with atmega644. So I burned in low fuse byte 0xBF to arduino board. Now, I have same problem with my arduino board. No response from it neither and no signal on crystal pins :-( I don't get it, I didn't change anything else than CKOUT bit in low fuse byte. I left everything else untouched. This shouldn't get result like that! Something is wrong with my programmer, obiously it burned some random fuses in.
What I noticed when programming fuses is, that low fuse byte was read 0xFF as default, like my writting didn't made any changes. I tryed again and then my arduino died...
Please, can someone help me, urgent! I really don't know what is going on anymore. I think this is the last time I am using avr's and their damn fuses. :-x

- - - Updated - - -

I have access to arduino nano or arduino uno thou. Can I make high voltage programmer with arduino nano or arduino uno somehow, to use it on my arduino mega2560?
 

I never had a problem with AVRs and I can't explain what goes wrong in your case and you are having all these problems.

I wonder is it's arduino's fault, I have always used AVR burn-o-mat to write the firmware and fuses (until I got an AVRISP and started using avr studio programmer). Burn-o-mat supports usbtiny as well as usbasp (I have used both).
 

I replaced AVR and programmed fuses and now it works. Probably I programmed "disable ISP" fuse bit, but I don't know how I managed to do that. So, problem is solved now.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…