Programming atmega32 clock source

In summary, the conversation discusses using an external 16MHZ crystal with an Atmega 32 microcontroller. The fuse settings for this are lowbyte=0xFF and highbyte=0Xc9. The question arises whether to set the fuse bits before or after programming, as the controller requires a clock source to be programmed. It is mentioned that the fuse bits will not have an effect until leaving programming mode. The controller also needs a clock source to program the flash, and reprogramming the fuse bits may require adjusting the lock bits. It is advised to make sure the external crystal is connected before leaving programming mode. The conversation also touches on the possibility of programming the flash without an external crystal, but this may vary depending on the
  • #1
asad1111
51
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
  • #2
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
 
  • #3
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?
 
  • #4
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.
 
  • #5


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.
 

1. What is the main purpose of programming the clock source for atmega32?

The clock source is responsible for providing a timing signal to the microcontroller, which is necessary for carrying out its instructions and operations. Programming the clock source ensures that the timing signal is accurate and consistent, which is crucial for the proper functioning of the atmega32.

2. What are the different clock sources that can be used for atmega32?

The atmega32 has three main clock sources: internal RC oscillator, external crystal, and external clock. The internal RC oscillator is the default clock source and has a frequency of 8 MHz. The external crystal and external clock can be connected to the microcontroller through specific pins and have a frequency range of 1-16 MHz.

3. How do I select the clock source for my atmega32?

The clock source can be selected by configuring the fuse bits in the atmega32's microcontroller. This can be done using a programming tool such as AVRISP or through the programming software. The appropriate fuse bit values can be found in the atmega32 datasheet.

4. Can the clock source be changed during runtime?

Yes, the clock source can be changed during runtime by modifying the clock prescaler register. This register controls the division factor of the clock source, allowing for the selection of a different frequency. However, changing the clock source during runtime may affect the timing of the microcontroller and should be done carefully.

5. What are the advantages and disadvantages of using an external crystal as the clock source for atmega32?

The external crystal provides a more accurate and stable clock signal compared to the internal RC oscillator. This is important for applications that require precise timing. However, using an external crystal also requires additional components and circuitry, making it more complex and expensive. Additionally, the external crystal may be susceptible to noise or interference, which can affect the accuracy of the timing signal.

Similar threads

  • Programming and Computer Science
Replies
22
Views
902
  • Electrical Engineering
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Electrical Engineering
Replies
1
Views
2K
  • Programming and Computer Science
Replies
7
Views
627
  • Special and General Relativity
Replies
20
Views
783
  • General Math
Replies
16
Views
2K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Programming and Computer Science
Replies
29
Views
3K
Back
Top