⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 模数转换.c

📁 模数转换的相关代码,调试正在进行!希望能对大家有些帮助@
💻 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 + -