336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


- AVCC : 아날로그 VCC가 연결되는 핀입니다.
- AREF : 아날로그 VCC의 기준 전압이 되는 핀입니다.
▼Datasheet에 나와있는 내용
AVCC : AVCC is the Analog Supply Voltage pin for Port F and the A/D Converter. 
It should be externally connected to VCC, even if the ADC is not used. 
If the ADC is used, it should be connected to VCC through a low-pass filter.
(Ranage : Vcc-0.3 ~ Vcc+0.3)


Link
The Atmega168 has 2 digital supply voltage pins, VCC and AVCC
AVCC supplies power to PC0-PC5. 
When these pins are used as analogue inputs, the AVCC power needs to be very stable.
This is achieved by using a low pass filter comprising of an inductor and capacitor.
(방금 위에서 언급했던 내용)

 
AREF : AREF is the analog reference pin for the A/D Converter.
(Aref = Vref)

AVCC, AREF를 함께 short시키고 Vcc로 묶어서 연결






//Program for ADC to read from channel 0 and show the 8 bit o/p on PORTB 
 
#include<avr/io.h>
#include<util/delay.h>
 
void ADC_init(void);
unsigned int ADC_read(unsigned char);
 
// ------------------------------------------------
int main(void)
{
unsigned int value;
DDRB=0xFF;                //포트B를 모두 출력으로 지정 (LED출력)
DDRD=0x03;                //0b00000011 으로 포트D의 0,1포트
ADC_init();             // Initialization of ADC
// ch=0;

while(1)
{
value=ADC_read(0);     //ADC0의 40번 핀을 ADC로 지정.......8비트resolution의 값
PORTB=value;                    //이값을 8비트의 LED출력으로 보낸다.
_delay_ms(500);
}
}
//------------------------------------------------
 
void ADC_init(void) // Initialization of ADC
{
ADMUX=(1<<REFS0); // AVcc with external capacitor at AREF
//ADMUX::REFS1 REFS0 ADLAR MUX4 MUX3 MUX2 MUX1 MUX0
//Vref is equal to AVcc
//ADC0 채널을 이용
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
// Enable ADC and set Prescaler division factor as 128
//ADCSRA::ADEN ADSC ADATE ADIF ADIE ADPS2 ADPS1 ADPS0
//ADEN은 필수로 Set, 나머지 비트는 Prescale따라서 조정 (128이 최고치)
}
 
unsigned int ADC_read(unsigned char ch)
{
ch= ch & 0b00000111; // channel must be b/w 0 to 7
ADMUX |= ch; // selecting channel
     
ADCSRA|=(1<<ADSC); // start conversion
while(!(ADCSRA & (1<<ADIF))); // waiting for ADIF, conversion complete
ADCSRA|=(1<<ADIF); // clearing of ADIF, it is done by writing 1 to it
 
return (ADC);
}


Posted by ElectricShock
:
BLOG main image
잡동사니들(지극히 개인취향인...) (다른글에도 댓글 부탁해요♥) You May Leave English Messages on GuestBook. by ElectricShock

공지사항

카테고리

분류 전체보기 (782)
Programming(=프로그래밍) (3)
MiDi (2)
Animation (4)
Blender (3D Graphic Program.. (10)
Blendtuts.com (Series) (1)
Blender 기초 팁들 (2)
Processing (디지털미디어과) (2)
Music (1)
Books in the world (0)
Communication(CAN, UART, et.. (12)
MCU Examples (PIC 기반) (7)
Transistor (1)
Mikro C Pro (11)
Mikro Pascal (1)
Proton IDE (0)
Robot (0)
Swift 3D (1)
Dummies Series (1)
All about Hacking (0)
제2 외국어 (1)
PIC 해외서적들 (3)
AVR (25)
PIC (MikroC) (MPLAB) (4)
Assembly (2)
ARM (3)
Arduino (26)
PSpice (1)
Proteus ISIS (14)
CodeVision (2)
FPGA (15)
MPLAB (24)
PCB (the Procedure) (15)
3D Printer (5)
PICKIT3 (6)
Matlab (11)
RaspBerry PI (15)
BeagleBone (1)
Android Studio (17)
졸업작품 (172)
Korea History (0)
Issue(사회) (73)
Multimeter 리뷰 (1)
Oscilloscope (1)
A (34)
B (19)
J (6)
C (32)
P (12)
T (37)
H (12)
I (12)
M (44)
R (5)
E (5)
F (2)
D (9)
O (2)
L (7)
S (9)
W (2)
V (6)
G (14)
Visual C++ or Visual Studio (2)
Android App Development (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백