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

📄 lcmeter-51cv2.c

📁 51单片机工程应用实例
💻 C
字号:
//2008/4/13 V2.0
//F=12MHz with LCD1602

#include <reg51.H>
#include <stdio.h>
#include <INTRINS.H>//_nop_()

typedef  unsigned char uchar;
typedef  unsigned int uint;

//LCD 1602
sbit	LCD_RS=P1^2;
sbit	LCD_E =P1^3;
sbit	LCD_D4=P1^4;
sbit	LCD_D5=P1^5;
sbit	LCD_D6=P1^6;
sbit	LCD_D7=P1^7;

//I/O
sbit 	BEP=P3^7;//Beep
sbit 	REL=P3^2;//relay
sbit 	CHK=P3^3;//测试按钮
sbit 	C_L=P3^4;//C/L switch
sbit 	FRQ=P3^5;//T1 

#define C2 1125//标准电容1000PF,实测值1155PF,计算取值1125pF

uint	cnt=0,F1=0,F2=0;
float 	C1;

const uchar table[]="0123456789";
union
	{
	uchar fc[2];
	uint  fi;
	}frecy;
/*-----------------------------------------------------------------------------
Public function prototypes
------------------------------------------------------------------------------*/
void LCD_init       (void);
void LCD_en_write   (void);
void LCD_write_char (uchar cd,uchar ab);
void LCD_set_xy     (uchar x, uchar y);
void LCD_write_str 	(uchar X,uchar Y,uchar *s);
void LCD_byte		(uchar abc);

void timer0			(void);
uint freq			(void);
void calc_C1		(void);
void calc_Cx		(void);
void calc_Lx		(void);
void disp_1			(uint temp);
void disp_2			(unsigned long temp);

void delay_nus		(uint n);
void del_ms         (uint n);
void bbb();						//蜂鸣

⌨️ 快捷键说明

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