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

📄 analog.c

📁 tcpip.rar 是一个51控制8019的程序,我已用于商用.还很稳定,有兴趣的可以看一下,对TCP IP UDP ICMP ARP RARP HTTP均可以实现.
💻 C
字号:
//-----------------------------------------------------------------------------
// Net ANALOG.C
//
// This module handles the analog inputs which are external temperature
// sensor, the on-chip temperature sensor, and operating voltage.
//-----------------------------------------------------------------------------
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <reg52.h>
#include "net.h"
#include "serial.h"
#include "analog.h"
#include <intrins.h>
	sbit adclk=P1^5;
	sbit addata=P1^6;
	sbit adcs=P1^7;
#define uchar unsigned char
#define uint  unsigned int
extern char xdata text[];
UINT idata cpu_temperature, air_temperature, cpu_voltage;
UCHAR idata mux_select;

/*********TLC549子程序***********************/
unsigned char ad(void)            //TLC549的采样子程序
{
//    unsigned char i,sample_data;
//	bit ea_flag;
//
//    ea_flag=EA;
//    EA=0;
//    adcs=0;
//    _nop_();
//    _nop_();
//    if(addata==1)
//    {
//        sample_data=1;
//    }
//    else
//    {
//        sample_data=0;
//    }
//    for(i=0;i<7;i++)
//    {
//        sample_data=(sample_data<<1);
//        adclk=1;
//        _nop_();
//        _nop_();
//        adclk=0;
//        if(addata==1)
//       {
//            sample_data=(sample_data|0x01);
//        }
//    }
//    adclk=1;
//    _nop_();
//    _nop_();
//    adclk=0;
//    _nop_();
//    _nop_();
//    
//    adcs=1;
//    EA=ea_flag;
    return 2500;

}
//--------------------------------------------------------------------------
// This function is a little state machine which reads one analog
// inputs at a time, out of the 3 possible inputs
//  1. On-chip temperature
//  2. External air temperature
//  3. CPU operating voltage
//--------------------------------------------------------------------------
void read_analog_inputs(void)
{
   cpu_temperature=2500;
   air_temperature=(uint)ad()*19;
   cpu_voltage=50;
}
 

⌨️ 快捷键说明

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