tempad.c

来自「一个热水器程序!三星9454单片机」· C语言 代码 · 共 37 行

C
37
字号
#include "Define1.h"

//******************************************************************
//*************************************************************************
//按键测试子过程(A/D转换方式进行)
uchar TempADcon(void)
{  
    uchar times = 0x5;
    uchar high  = 0xff;
    uchar AD2=0xff;
    ////di;可以不禁止中断
    Clr_WatchDog;
    while(times)
    {
      ADCON =0x77 ;//0x83 P26 is AD covert 0x47;//0x11;//0x27;//0x41; 0x39;     select P0.4 is AD input  //selectP0.1// P0.2is as AD convert,input clock=Fosc/1     
      while(!Test_ADOK);      //一直等转换结束标志,注意有分号!!!
      if  (ADDATAH  < high)   //The data in ADDATAH is 8; in ADDATAL is 2. 
          high = ADDATAH;
      times--;
    }     
    

   if  ((high>0xfD)&&(high <0xff))AD2=0x01; //E9
   
   if  ((high>2)&&(high <0xfD))AD2=high; //Temp AD2
   
   if  ((high>0)&&(high <2))AD2=0x03;//E1
     
    ////ei;   
    return  (AD2);   //rede AD data.
}





⌨️ 快捷键说明

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