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

📄 main.c

📁 本程序能实现温度的实时采集与显示
💻 C
字号:
#include <REG1210.H>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define LSB 298.0232e-9
#define ALPHA 2664.7
extern void autobaud(void);
extern long bipolar(void);

void main()
{
 float volts,lr,ave;
 int i,k,decimation,samples;
 decimation=1728;
 CKCON=0;
 autobaud();
 printf("MSC1210 ADC teperature test :\n");
 USEC=10;
 ACLK=9;
 ADMUX=0x08;
 PDCON&=0xF7;
 //ODAC=0x00;
 ADCON0=0x30;//pga=1
 ADCON2=decimation&0xff;
 ADCON3=(decimation>>8)&0x07;
 ADCON1=0x01;
 printf("Calibrating......\n");
 for (k=0;k<4;k++)
 {
  while (!(AIE&0x20));
  lr=bipolar();
 }
 //ODAC=0x7f;
 samples=10;
 while(1)
 {
  ave=0;
  for (i=0;i<samples;i++)
  {
   while(!(AIE&0x20));
   ave+=bipolar()*LSB;
  }
  volts=ave/samples;

  printf("volts=%f\r\n",volts);
 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -