Programming atmega32 clock source

Click For Summary

Discussion Overview

The discussion centers around the use of an external 16MHz crystal as a clock source for the ATmega32 microcontroller, specifically addressing the timing of setting fuse bits in relation to programming the device. Participants explore the implications of fuse settings on programming capabilities and the necessity of a clock source during the programming process.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant questions whether fuse bits should be set before or after programming, noting the potential requirement for an external crystal during programming.
  • Another participant asserts that fuse bits are latched when leaving programming mode, indicating that an external crystal is not needed until after programming.
  • A participant expresses concern about reprogramming the flash memory without an external crystal if the fuse bits are set to use one.
  • There is a suggestion that some microcontrollers might switch to an internal oscillator during programming, allowing flash programming without an external clock, though uncertainty exists regarding the ATmega32's behavior in this regard.
  • One participant recommends setting the fuse bits before programming to avoid complications, emphasizing the importance of correct clock source settings.
  • There is mention of the possibility of needing a different programming method or tool to reprogram the ATmega32 after setting the fuse bits, particularly if an external clock source is required.

Areas of Agreement / Disagreement

Participants express differing views on the necessity of an external clock source for programming the ATmega32 after setting the fuse bits. While some suggest it is essential, others indicate that it may not be required depending on the microcontroller's behavior.

Contextual Notes

Participants reference the user manual and datasheet for the ATmega32 for further clarification on fuse bits and programming methods, indicating that specific details may vary based on the programming tool used and the microcontroller's design.

asad1111
Messages
51
Reaction score
0
iam using atmega 32 and i want to use external 16MHZ crystal I have figured out the fuse setting for this as lowbuyte=0xFF and highbyte=0Xc9
what i cannot understand is should i set fuse bits before programming or after programming? because as i have specified external crystal as clock source if i set fuse bits before programming it will require external crytal to be programmed (iam assuming controller requires clock source to be programmed does it?)and if i set the fuse bits after programming how will i reprogram it?

Iam using a universal burner to programme atmega32
 
Engineering news on Phys.org
As I remember, the Atmega 32 latches the fuses when you leave the programming mode. So even if you program the fuse bits, they won't have effect until you leave the programming mode. So the answer to your question is that, you don't need the external crystal before you leave the programming mode.

And yes the controller needs a clock source to be able to program the flash.

If you want to reprogram the fuse bits, there is something about the Lock bits that you need to do. So read up on the lock bits in the user manual.

Sidenote: I heard of some guys who programmed the fuse bit for an external crystal, left the programming mode, but they had no external crystal, so the controller didn't do anything. So be sure the crystal is connected and all before you program the fuse bits and leave programming mode. :D
 
thanks runie I have an external crystal so that won't be a problem but can i reprogram the flash (not the fuse bits ) without using external crystal?since i have set the fused bits to external crystal from where will it get the clock to reprogram flash?
 
I believe it will need the clock from the external source then. So if you remove the crystal, then you can't program the flash.

However, some microcontrollers do it, such that when you enter programming mode, it switches to the internal oscillator. Thus you can always program the flash. But I don't know if this is the case with the ATmega 32.

The User Manual should tell you more.
 


I would recommend setting the fuse bits before programming the atmega32. This is because the fuse bits control important settings such as the clock source, and it is important to have them set correctly before programming. If you set the fuse bits after programming, you may encounter difficulties in reprogramming the atmega32 if the clock source is not properly set.

In order to reprogram the atmega32 after setting the fuse bits, you may need to use a different programming method or tool. For example, some universal burners have the capability to reprogram fuses after programming the microcontroller. You may also need to use an external clock source, such as a crystal oscillator, to temporarily provide the correct clock signal for programming.

It is important to carefully read the instructions and specifications for your specific universal burner to ensure that you are using the correct method for programming and setting the fuse bits. Additionally, consulting the datasheet for the atmega32 can provide more detailed information about the programming process and recommended methods.
 

Similar threads

Replies
2
Views
3K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
7
Views
4K
  • · Replies 16 ·
Replies
16
Views
3K
Replies
2
Views
6K
  • Sticky
  • · Replies 13 ·
Replies
13
Views
8K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K