˜Ë(bi¨¡o)î}: 6410ADCŸo(w¨²)òŒ(q¨±)„Ó(d¨°ng)Ö±½Ó²Ù×÷³ÌÐò [´òÓ¡±¾í“(y¨¨)]
×÷Õß: hei51hei •r(sh¨ª)ég: 2018-3-20 14:11
˜Ë(bi¨¡o)î}: 6410ADCŸo(w¨²)òŒ(q¨±)„Ó(d¨°ng)Ö±½Ó²Ù×÷³ÌÐò
#defineGLOBAL_CLK 1
#include<stdlib.h>
#include<string.h>
#include"def.h"
#include"option.h"
#include"2440addr.h"
#include"2440lib.h"
#include"2440slib.h"
#include"mmu.h"
#include"profile.h"
#include"memtest.h"
int Readadc(intch)
{
rADCCON= (1<<14)| (49<<6) | ((ch)<<3);//adcʹÄÜ£¬ÔO(sh¨¨)ÖÃîlÂÊžé1MHZ
rADCTSC=~(0x1<<2);//adcÔO(sh¨¨)ÖÞéÆÕͨÞD(zhu¨£n)“Qģʽ
rADCCON|=0x1;//†¢„Ó(d¨°ng)ad
while(rADCCON0x1);//µÈ´ýadÞD(zhu¨£n)“Qé_(k¨¡i)ʼ
while(!(rADCCON(0x1<<15)));//µÈ´ýadÞD(zhu¨£n)“Q½Y(ji¨¦)Êø
return(rADCDAT0 0x3ff); //×xÈ¡A/DÞD(zhu¨£n)“QµÄ”µ(sh¨´)“þ(j¨´)
}
void Main()
{float v0,v1;
int t0,t1;
Uart_Printf("Õˆ(q¨«ng)Õ{(di¨¤o)Õû»¬„Ó(d¨°ng)ëŠ×貢ݔÈë1ßx“ñï@ʾ늉ºÖµ£¡\r");
while(Uart_GetIntNum()==1)
{v0=((float)Readadc(0)*3.3)/1024.0;//Ó‹(j¨¬)Ëã늉ºÖµ
v1=((float)Readadc(1)*3.3)/1024.0;//Ó‹(j¨¬)Ëã늉ºÖµ
t0=(v0-(int)v0)*1000;//Ó‹(j¨¬)ËãС”µ(sh¨´)²¿·Ö£¬Uart_Printfº¯”µ(sh¨´)Ÿo(w¨²)·¨´òÓ¡¸¡üc(di¨£n)”µ(sh¨´)
t1=(v1-(int)v1)*1000;//Ó‹(j¨¬)ËãС”µ(sh¨´)²¿·Ö£¬Uart_Printfº¯”µ(sh¨´)Ÿo(w¨²)·¨´òÓ¡¸¡üc(di¨£n)”µ(sh¨´)
Uart_Printf("늉ºÖµžéAIN0£º%d.%-3dVAIN1:%d.%-3dV\r",(int)v0,t0,(int)v1,t1);
Uart_Printf("\n");}}
šgÓ¹âÅR (http://www.torrancerestoration.com/bbs/) |
Powered by Discuz! X3.1 |