Naver
[open 16f877a 고장] :: ▶LINK ▶LINK 두개 링크를 참고해주세요 (댓글 환영합니다.)
http://treehouseprojects.ca/fusebits/
Setting Up An External Crystal Clock Source (with Fuse Bits) for AVR ATMega Microcontrollers
Choosing the values for the fuse bits
Just to make sure we are on the same page,
CKSEL3..0 means all the CKSEL bits from CKSEL0 to CKSEL3.
CKSEL stands for clock select,
and tells our microcontroller what kind of a clock we are using,
what its frequency is.
Let's look at Table 2 :
Table 2. Device Clocking Options Select
Device Clocking |
CKSEL3..0 |
External Crystal / Ceramic Resonator |
111 - 1010 |
External Low Freq Crystal |
1001 |
External RC Oscillator |
1000 - 0101 |
Calibrated Internal RC |
0100 - 0001 |
External Clock |
0000 |
Note : For all fuses "1" means unprogrammed while "0" means programmed
Default가 1이다.
From this, we see that CKSEL3..0 has to be somewhere between 1111 and 1010.
여기서, 우린 본다. that CKSEL3..0이 있어야만한다고 어딘가에 between 1111 & 1010.
So the four bits (CKSEL0, CKSEL1, CKSEL2, CKSEL3) are somewhere in that range.
그렇게 the 4개 비트들 (CKSEL 0 ~ 3)은 있다. 어딘가에 in that range에.
How do we know what they are exactly?
That depends on our crystal’s frequency,
어떻게 우리가 아는가? 그게 정확한지?
그건 의존한다. on 우리의 크리스탈 주파수에.
Table 2 is just telling us that
if we use an external crystal,
the four bits will be somewhere in that range.
Right, moving forward.
테이블2 (▲위 폴더) 는 그저 말해준다. 우리에게
만약 우리가 사용한다면 an 외부 크리스탈을,
the 4개 비트들은 will be 있게될거다. 어딘가에 in that range에.
Table 4. Crystal Oscillator Operating Modes
CKOPT |
CKSEL3..1 |
Freq. Range(MHz) |
Recommended Range for Caps. (pF) |
1 |
101 |
0.4 - 0.9 |
- |
1 |
110 |
0.9 - 3.0 |
12-22 |
1 |
111 |
3.0 - 8.0 |
12-22 |
0 |
101,110,111 |
1.0 ≤ |
12-22 |
Note: This option should not be used with crystals, only with ceramic resonators
Table 4 gives us some more detail about CKSEL3..1 (Note, not CKSEL0 just yet),
and
tells us what our options for CKOPT are.
We will program CKOPT (set to Zero)
because a programmed CKOPT is needed
when we are dealing with higher frequency ranges,
need a full swing signal,
or we are driving a second buffer with the same output from the clock.
We meet the first criteria (16MHz > 1MHz),
so we will set CKOPT to 0.
As a result CKSEL3..1 can be any of 101,110,111,
it doesn't matter.
We'll go with setting the three CKSEL bits to 111 just for kicks.
Good. let's move on to the final three bits
we have to work on
: CKSEL0, SUT1, and SUT0.
.
.
.
Setting Up the Hardware
Finally, you are at the point at which you are ready to burn the fuse bits
into your microcontroller.
최종적으로, 넌 있다. at the 포인트에 at which 네가 준비하는시점에 to 굽기위한 the 퓨즈비트를
into 너의 마이크로컨트롤러에.
But you want to make sure you have the crystal connected to your AVR too,
so follow the schematic below;
하지만, 넌 want to 확인하길원한다. 네가 갖고있는지 the 크리스탈 연결되있는지 to AVR에,
so 따라가라 the 회로를 below;
C1 and C2 and 22pF ceramic capacitors.
Have this setup as close together as possible,
don't have wires running around the breadboard to reach the crystal and ground.
You could use the following setup to try out the impact of the crystal along with the following code (skip this little bit if you don't want to try out a simple example)
▼▼▼▼▼▼▼▼▼▼▼▼▼
/*
*CrystalTest.c
*This simple code is meant to teach how an external crystal works for an AVR ATMega
*by flashing an LED ON and OFF every 200 milliseconds
*/
//This tells the AVR how many Cycles equates to One second
//For this code, we are using the internal 1 MHz crystal, so we have F_CPU defined as 1 million
#ifndef F_CPU
#define F_CPU 1000000UL //1 million
#endif
#include<avr/io.h>
#include<util.delay.h>
int main(void)
{
DDRC = (1<<RC5);
while(1)
{
//LED on
PortC = (1<<PC5);
_delay_ms(200);
//LED off
PortC = (0<<PC5);
_delay_ms(200);
}
}
▲▲▲▲▲▲▲▲▲▲▲▲▲
======================================================================================================================
http://www.instructables.com/id/Avr-fuse-basics-Running-an-avr-with-an-external-cl/?ALLSTEPS
.
.
.
Step 6: Summing up.
Now, the chip is sitting with its default fuse byte configuration.
First of all we need to decide, how to run the microcontroller?
But where to get the options
The options are available at CKSEL3 to CKSEL0
Hmm, but there is a range of values for that, 1111-1010.
For this, we look up at another table,
Initially the high fuse byte setting was-
우린 성공적으로 마무리지었다. 선택하는데 the set of Low Fuse Byte를.
6)WDTON - 1
5)SPIEN -0
4)CKOPT -1
3)EESAVE -1
2)BOOTSZ1 -0
1)BOOTSZ0 -0
0)BOOTRST -1
Now we have to change them to-
7)RSTDISBL -1
6)WDTON -1
5)SPIEN -0
4)CKOPT -0
3)EESAVE -1
2)BOOTSZ1 -0
1)BOOTSZ0 -0
0)BOOTRST -1
Now for the low fuse byte, intially it was-
7)BODLEVEL -1
6)BODEN -1
5)SUT1 -1
4)SUT0 -0
3)CKSEL3 -0
2)CKSEL2 -0
1)CKSEL1 -0
0) CKSEL0 -1
We are changing it to-
7)BODLEVEL -1
6)BODEN -1
5)SUT1 -1
4)SUT0 -1
3)CKSEL3 -1
2)CKSEL2 -1
1)CKSEL1 -1
0) CKSEL0 -1
That is 11111111 in binary or FF in hexadecimal.
avrdude -c usbasp -p m8 -U lfuse:w:0b11111111:m -U hfuse:w:0b11001001:m
But it is better to write this in hexadecimal, like-
avrdude -c usbasp -p m8 -U lfuse:w:0xff:m -U hfuse:w:0xC9:m
avrdude -p atmega8 -c usbasp -U lfuse:w:0xE1:m -U hfuse:w:0xD9:m
Finally, the total procedure ends here.
==========================================================
http://mulgu.kr/entry/Code-Example-ATMEGA848-UART-%EC%98%88%EC%A0%9C%EC%86%8C%EC%8A%A4