?? 模數(shù)轉換.c
字號:
#define uint unsigned int
#define uchar unsigned char
#include <iom16v.h>
#include <macros.h>
#include "SP027法度.h"
void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0xFF;
PORTD = 0x00;
DDRD = 0xFF;
}
uint ADC_Convert(void)
{
uint temp;
uchar temph,templ;
templ=ADCL;
temph=ADCH;
temp=temph;
temp<<=8;
temp=temp+templ;
return temp;
}
//
void main(void)
{
uint temp,v;
double m;
uchar temph,templ;
port_init();
/*ADMUX=0X00;
ADCSRA=0XE3;*/
ADCSR = 0x00; //disable adc
ADMUX = 0x40; //select adc input 0
ACSR = 0x80;
ADCSR = 0xec;
SFIOR=0x00;
while(1)
{
templ=ADCL;
temph=ADCH;
temp=temph;
temp=(temp*256+templ);
m=(double)temp;
v=(uint)(5*m*1000/1024);
CLS();
DispNum(v);
Delay(200);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -