728x90
반응형
ADC(써미스터)
#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;
}
========================================================================================================================================
#include "adc.h"
void adc_Init (void) // ADLAR=1 왼족 정렬
{
ADMUX = (0 << REFS1) | (0 << REFS0) | (1 << 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)
{
ADCSRA = ADCSRA | (1 << ADSC);
{
ADCSRA = ADCSRA | (1 << ADSC);
while( 0 != (ADCSRA & (1 << ADSC)) );
return ADCH; // 10 bit 중 뒤에 2bit 버림.
return ADCH; // 10 bit 중 뒤에 2bit 버림.
}
========================================================================================================================================
#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__
========================================================================================================================================
PWM(Pulse Width Modulator)
- 펄스폭 (전기적 신호의 폭)을 변조.
728x90
'코스웨어 > 16년 스마트컨트롤러' 카테고리의 다른 글
20160324_조재찬_업무일지_펌웨어(써미스터,PWM) (0) | 2016.03.25 |
---|---|
20160324-업무보고-이보원-써미스터 사용 실습 (0) | 2016.03.25 |
20160318_김도관_업무일지_타이머자동증가&스위치제어 (0) | 2016.03.25 |
20160324_장진웅_업무일지_저항&써미스터 (0) | 2016.03.24 |
2016_03_24_업무일지_노태경 (0) | 2016.03.24 |
2016 03 24 업무일지 오전 저항과 써미스터 (0) | 2016.03.24 |
20160323_김가연_업무일지_ADC (0) | 2016.03.24 |
20160323_장진웅_업무일지_컨버터, 타이밍도,ADC (0) | 2016.03.24 |