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

📄 ad7705.lst

📁 液晶显示屏12232的驱动程序.内包含了EEPROM及AD7705的驱动程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 210          void AD7705_reset(void)
 211          {
 212   1         AD_RST=1;
 213   1         delay();
 214   1         AD_RST=0;
 215   1         delay();
 216   1         AD_RST=1;
 217   1         delay();
 218   1         AD_CS=0;
 219   1      }
 220          
 221          unsigned int ReadDataCh1_Ch2(bit mode)
 222             {     
 223   1           uint AD16bit;
 224   1           uchar i,DataH,DataL; //AD值的高位与低位
 225   1               DataH=0;
 226   1               DataL=0;
 227   1               if(mode==1)
 228   1                    writeword(0x39);
 229   1               else
 230   1                writeword(0x38);
 231   1           while(AD_REDY==1); //等待数据准备好
 232   1               delay();
 233   1           AD_CLK=1;
 234   1           AD_CS=0;
 235   1           delay();
 236   1           AD16bit=0;
 237   1               AD_OUT=1;
 238   1      /*       for(i=0;i<8;i++)
 239   1               {
 240   1                   AD_CLK=0;
 241   1                       DataH<<=1;
C51 COMPILER V7.50   AD7705                                                                05/28/2007 15:49:33 PAGE 5   

 242   1                       delay();
 243   1                       AD_CLK=1;
 244   1                       delay();
 245   1                       if(AD_OUT==1)
 246   1                           DataH|=0x01;
 247   1               }
 248   1              // DataH=DataH&0xff;
 249   1               for(i=0;i<8;i++)
 250   1               {
 251   1                   AD_CLK=0;
 252   1                       DataL<<=1;
 253   1                       delay();
 254   1                       AD_CLK=1;
 255   1                       delay();
 256   1                       if(AD_OUT==1)
 257   1                           DataL|=0x01;
 258   1               }      */
 259   1               for(i=0;i<16;i++)
 260   1            {
 261   2              AD16bit=AD16bit<<1;
 262   2              AD_CLK=0;
 263   2      //              if(i<15)
 264   2      //              AD16bit=AD16bit<<1;
 265   2              delay();
 266   2                      AD_CLK=1;
 267   2                      delay();
 268   2              if(AD_OUT==1)
 269   2                          AD16bit|=0x01;//读取数据位
 270   2              // DataL=DataL&0xff;
 271   2                 }
 272   1           delay();
 273   1           while(AD_REDY==0);
 274   1           AD_CS=1;
 275   1               //AD16bit=DataH*256+DataL;
 276   1           return(AD16bit);
 277   1      }
 278          
 279             void delay()
 280              { 
 281   1            unsigned int j;
 282   1            for(j=0;j<8;j++);
 283   1          }
 284          
 285          void INI7705(void)
 286             {
 287   1           writeword(0xff);
 288   1           writeword(0xff);
 289   1           writeword(0xff);
 290   1           writeword(0xff);
 291   1           writeword(0xff);
 292   1         }
 293          /*
 294          bit START_CH1(void)
 295               {
 296               bit temp=0;
 297               INI7705();
 298               WRITE7705(0x20);
 299               WRITE7705(0x0a);           //0x0c
 300               WRITE7705(0x10);
 301               WRITE7705(0x40);    //setup setup reg.
 302          
 303               ad7705timer=0;
C51 COMPILER V7.50   AD7705                                                                05/28/2007 15:49:33 PAGE 6   

 304               while(ad7705timer<50)
 305                   {
 306                   if(DRDY_7705)
 307                     {
 308                     temp=1;
 309                     ad7705timer=51;
 310                     }
 311                   }
 312               if(!temp) return(0);
 313          
 314               ad7705timer=0;
 315               while(ad7705timer<50)
 316                   {
 317                   if(!DRDY_7705)
 318                     {
 319                     return(1);
 320                     }
 321                   }
 322               return(0);
 323               }
 324          
 325          unsigned int READ_CH1(void)
 326               {
 327               idata unsigned int y;
 328               START_CH1();/////////////////////////////
 329               ad7705timer=0;
 330               while(ad7705timer<50)
 331                   {
 332                   if(DRDY_7705)
 333                     {
 334                     ad7705timer=51;
 335                     }
 336                   }
 337               ad7705timer=0;
 338               while(ad7705timer<50)
 339                   {
 340                   if(!DRDY_7705)
 341                     {
 342                     ad7705timer=51;
 343                     }
 344                   }
 345               WRITE7705(0x38);
 346               y=READ7705();
 347             return y;
 348                }
 349          
 350           bit START_CH2(void)
 351               {
 352               bit temp=0;
 353               INI7705();
 354               WRITE7705(0x21);
 355               WRITE7705(0x0a);      //0x0c
 356               WRITE7705(0x11);
 357               WRITE7705(0x40);
 358          
 359               ad7705timer=0;
 360               while(ad7705timer<50)
 361                   {
 362                   if(DRDY_7705)
 363                     {
 364                     temp=1;
 365                     ad7705timer=51;
C51 COMPILER V7.50   AD7705                                                                05/28/2007 15:49:33 PAGE 7   

 366                     }
 367                   }
 368               if(!temp) return(0);
 369          
 370               ad7705timer=0;
 371               while(ad7705timer<50)
 372                   {
 373                   if(!DRDY_7705)
 374                     {
 375                     return(1);
 376                     }
 377                   }
 378               return(0);
 379               }
 380          
 381          unsigned int READ_CH2(void)
 382               {
 383               idata unsigned int y;
 384               START_CH2();/////////////////////////////自己整加部分
 385               ad7705timer=0;
 386               while(ad7705timer<50)
 387                   {
 388                   if(DRDY_7705)
 389                               {
 390                               ad7705timer=51;
 391                               }
 392                   }
 393               ad7705timer=0;
 394               while(ad7705timer<50)
 395                   {
 396                   if(!DRDY_7705)
 397                                {
 398                                ad7705timer=51;
 399                                }
 400                   }
 401               WRITE7705(0x39);
 402               y=READ7705();
 403              return y;
 404               }
 405                   #endif
 406          */
 407          
 408          
 409          
 410          
 411          
 412          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    609    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      3      19
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       1
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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