728x90
반응형
ADC(Analog Digital Converter)
- ADC (EX. 녹음)
- DAC (EX. 재생)
*ADC 특징
• 10-bit Resolution
• 1 LSB Integral Non-linearity
• ±2 LSB Absolute Accuracy
• 13μs - 260μs Conversion Time
• Up to 76.9kSPS (Up to 15kSPS at Maximum Resolution)
• 16 Multiplexed Single Ended Input Channels
• 14 Differential input channels
• 4 Differential Input Channels with Optional Gain of 10× and 200×
• Optional Left Adjustment for ADC Result Readout
• 0V - VCC ADC Input Voltage Range
• 2.7V - VCC Differential ADC Voltage Range
• Selectable 2.56V or 1.1V ADC Reference Voltage
• Free Running or Single Conversion Mode
• Interrupt on ADC Conversion Complete
• Sleep Mode Noise Canceler
*MUX (MULTIPLEXER)
- 여러개 중 하나를 선택하는 것. ->> 여러개 PIN중 하나를 선택하는 것.
- ADC[15:0]
==========================================================================================================
#include "adc.h"
void adc_Init (void) // ADLAR=0 오른족정렬 사용
{
ADMUX = (0 << REFS1) | (0 << REFS0) | (0 << ADLAR) | (0 << MUX4) | (0 << MUX3) | (0 << MUX2) | (0 << MUX1) | (0 << MUX0);
ADCSRB = (0 << ACME) | (0 << MUX5) | (0 << ADTS2) | (0 << ADTS1) | (0 << ADTS0); // ADC0 사용.
ADCSRA = (1 << ADEN) | (0 << ADSC) | (0 << ADATE) | (0 << ADIF) | (0 << ADIE) | (1 << ADPS2) | (1 << ADPS1) | (0 << ADPS0);
//64분주 사용
}
}
unsigned int adc_Run0 (void)
{
adc_Init();
ADCSRA = ADCSRA | (1 << ADSC);
{
adc_Init();
ADCSRA = ADCSRA | (1 << ADSC);
while( 0 != (ADCSRA & (1 << ADSC)) );
return ADC;
return ADC;
}
==========================================================================================================
#ifndef __ADC_H__
#define __ADC_H__
#define __ADC_H__
#include "main.h"
void adc_Init (void);
unsigned int adc_Run0 (void);
unsigned int adc_Run0 (void);
#endif //__ADC_H__
==========================================================================================================
#include "main.h"
#include "lcd.h"
#include "tc0.h"
#include "usart.h"
#include "adc.h"
#include "lcd.h"
#include "tc0.h"
#include "usart.h"
#include "adc.h"
int main(void)
{
char caVal[] = "....";
unsigned int uiVal;
lcd_Init (); // 함수 초기화
usart1_Init ();
adc_Init();
while(1)
{
uiVal = adc_Run0(); // ADC 값
{
char caVal[] = "....";
unsigned int uiVal;
lcd_Init (); // 함수 초기화
usart1_Init ();
adc_Init();
while(1)
{
uiVal = adc_Run0(); // ADC 값
caVal[0] = '0' + (uiVal / 1000); // 각자리수 추출
caVal[1] = '0' + ((uiVal % 1000) / 100);
caVal[2] = '0' + ((uiVal % 100) / 10);
caVal[3] = '0' + (uiVal % 10);
caVal[1] = '0' + ((uiVal % 1000) / 100);
caVal[2] = '0' + ((uiVal % 100) / 10);
caVal[3] = '0' + (uiVal % 10);
lcd_Str(caVal); // lcd 출력
usart1_Str(caVal);
lcd_Inst(LCD_HOME);
}
usart1_Str(caVal);
lcd_Inst(LCD_HOME);
}
return 0;
}
728x90
'코스웨어 > 16년 스마트컨트롤러' 카테고리의 다른 글
20160323_조재찬_업무일지_펌웨어(ADC) (0) | 2016.03.24 |
---|---|
20160323-업무보고-이보원-ADC – Analog to Digital Converter (0) | 2016.03.24 |
20160323_업무일지_박진한_ADC (1) | 2016.03.24 |
ADC (0) | 2016.03.23 |
2016_03_23_타이밍도_노태경_업무일지 (0) | 2016.03.23 |
20160322_조재찬_업무일지_펌웨어(USART) (0) | 2016.03.23 |
2016-3-17.강정수.Lcd출력 (2) | 2016.03.23 |
20160322_김가연_업무일지_USART Rx Tx 시리얼 통신 (0) | 2016.03.23 |