原创 1602 频率测量proteus程序

2009-5-14 10:59 1962 2 2 分类: MCU/ 嵌入式

https://assets-stash.oss-cn-shanghai.aliyuncs.com/album/old-resources/2009/5/14/7bd8bbfd-1c06-4f42-8b0e-c4d3704a030e.rar
#include <reg51.h>
#include "LCD1602.h"
#include "stdio.h"
float fre;
unsigned int cnt,t1count;


sbit s0=P3^0;
sbit s1=P3^1;
sbit s2=P3^2;


void Delay1ms(unsigned int count)
{
 unsigned int i,j;
 for(i=0;i<count;i++)
 for(j=0;j<120;j++);
}


 void delay (int m)
{
 unsigned char i,j;
 for (i=0;i<m;i++)
 for (j=0;j<253;j++);
}


   void T1_ISP(void) interrupt 3
{
  t1count ++;
  TL1=0;
  TH1=0;
}


 void Timer_Init (void)
{
 TMOD=0x52;
    TH0=0x06;
    TL0=0x06;
    EA="1";
    ET0=1;
    ET1=1;


}


void T0_ISP(void) interrupt 1
{
 cnt++;
 if (cnt==4000)
 {
  cnt=0;
     EA="0";
       fre="65536"*t1count+256*TH1+TL1;   
   
 }
   
}


 



main()
{  
   unsigned int value = 0;
   unsigned char buffer[40];
   Timer_Init();
   while (1)
    {
      if (s0==0)
       {
       delay (2);
        if (s0==0)
       TR0=1;
      TR1=1;
         LCD_Initial();
       GotoXY(0,0);
      Print("    Frequency");
 
      while(1)
       {
     GotoXY(0,1);  
     sprintf(buffer,"%f",fre);
     Print(buffer);
     Delay1ms(200);
       }      
        }


  if (s1==0)
       {
       delay (2);
        if (s1==0)
       TR0=1;
      TR1=1;
         LCD_Initial();
       GotoXY(0,0);
      Print("    period(s)");
 
      while(1)
       {
     GotoXY(0,1);  
     sprintf(buffer,"%f",1/fre);
     Print(buffer);
     Delay1ms(200);
       }      
        }


  if (s2==0)
       {
       delay (2);
        if (s2==0)
       TR0=1;
      TR1=1;
         LCD_Initial();
       GotoXY(0,0);
      Print("    venation");
 
      while(1)
       {
     GotoXY(0,1);  
     sprintf(buffer,"%f",2/fre);
     Print(buffer);
     Delay1ms(200);
       }      
        }
     }
}

文章评论0条评论)

登录后参与讨论
相关推荐阅读
aas7502987 2012-04-07 11:48
51/STC最小系统板资料(更新中)
图片欣赏    淘宝网址:http://item.taobao.com/auction/item_detail.htm?item_num_id=9073446988  二   程...
aas7502987 2011-10-13 22:59
YL-3 资料
YL-3数码管模块资料:YL-3 串行数码管资料.zip...
aas7502987 2011-09-24 09:10
USB转TTL小板驱动
xp系统驱动:XP系统支持STC下载的PL-2303HX新版驱动.rar WIN7系统驱动:WIN7系统支持STC下载的PL2303HX驱动.rar...
aas7502987 2011-05-24 22:48
STM32F103RBT6最小系统原理图 PCB
STM32F103RBT6最小系统板原理图 PCB 附件:做好的成品板:淘宝链接网址:http://item.taobao.com/item.htm?id=8864376956...
aas7502987 2011-05-08 12:53
YL-16 STM32F103最小系统板资料(更新中)
二 数据手册:  USB协议中文版:attachment download  中文数据手册:attachment downloadSTM32选型手册:attachment downloadSTM32勘...
aas7502987 2011-03-20 13:27
DS18B20温度测量模块
DS18B20 数码管温度显示程序:...
我要评论
0
2
1
2
3
4
5
6
7
8
9
0
关闭 热点推荐上一条 /4 下一条