📄 main.c
字号:
dis_one_char(0,7,temp1+0x30,1);
dis_one_char(0,8,temp2+0x30,1);
break;
}
case 1:
{
if(temp1==0 && temp0==0)
dis_one_char(0,5,0x7f,0);
dis_one_char(0,6,temp1+0x30,1);
dis_one_char(0,7,'.',1);
dis_one_char(0,8,temp2+0x30,1);
break;
}
case 2:
{
dis_one_char(0,6,temp1+0x30,1);
if(temp1==0 && temp0==0)
dis_one_char(0,6,0x7f,0);
dis_one_char(0,7,temp2+0x30,1);
dis_one_char(0,8,'.',1);
break;
}
default:
break;
}
//--------------------------------------------------------------------
if(danwei=='K' && point==1)
{
temp=1000000/temp;
temp&=0x0000ffff;
temp_to_tempx(temp);
danwei_t='u';
}
if(danwei=='K' && point==2)
{
temp=100000000/temp;
temp&=0x0000ffff;
temp_to_tempx(temp);
danwei_t='n';
}
if(danwei=='M' && point==0)
{
temp=10000000/temp;
temp&=0x0000ffff;
temp_to_tempx(temp);
danwei_t='n';
}
if(danwei=='M' && point==1)
{
temp=1000000/temp;
temp&=0x0000ffff;
temp_to_tempx(temp);
danwei_t='n';
}
dis_one_zi(2,0,x51,1,1);//周
dis_one_zi(2,1,x52,1,1);//期
dis_one_char(2,11,0x7f,0);
dis_one_char(2,12,danwei_t,1);
dis_one_char(2,13,'S',1);
dis_one_char(2,14,0x7f,0);
dis_one_char(2,15,0x7f,0);
dis_one_char(2,4,0x7f,0);
if(temp==65535)
{
dis_one_char(2,6,'O',1);
dis_one_char(2,7,'V',1);
dis_one_char(2,8,'E',1);
dis_one_char(2,9,'R',1);
dis_one_char(2,10,'!',1);
}
else
{
dis_one_char(2,6,temp0+0x30,1);
if(temp0==0)
dis_one_char(2,6,0x7f,0);
dis_one_char(2,7,temp1+0x30,1);
if(temp0==0 && temp1==0)
dis_one_char(2,7,0x7f,0);
dis_one_char(2,8,temp2+0x30,1);
if(temp0==0 && temp1==0 && temp2==0)
dis_one_char(2,8,0x7f,0);
dis_one_char(2,9,temp3+0x30,1);
if(temp0==0 && temp1==0 && temp2==0 && temp3==0)
dis_one_char(2,9 ,0x7f,0);
dis_one_char(2,10,temp4+0x30,1);
}
}
//--------------------------------------------------------------------
void delay_1(uchar time)
{
while(--time!=0)
delay(50000);
}
//--------------------------------------------------------------------
void freq() //频率计子程序
{
unsigned long temp=0x30;
uchar del=5;
timer_init();
reset: gate=4;
sel_x(100);
a1=1;
a2='M';
while(1)
{
//---------------------------------------------------
key1=1;
key0=1;
delay_1(5);
if(key0==0 || key1==0)
goto exit;
temp=temp_h*256+temp_l;
if(TF1)
{
TF1=0;
TH1=0;
TL1=0;
dis_cls();
dis_one_zi(0,0,x43,1,1);
dis_one_zi(0,1,x44,1,1);
dis_one_zi(0,2,x45,1,1);
dis_one_zi(0,3,x46,1,1);
dis_one_zi(0,4,x47,1,1);
dis_one_zi(0,5,x48,1,1);
dis_one_zi(0,6,x49,1,1);
dis_one_zi(0,7,x50,1,1);
goto reset;
}
temp=temp_h*256+temp_l;
if(sel_100==1 && temp<=5000 && gate==4)
{
sel_x(10);
a1=0;
a2='M';
delay_1(del);
}
temp=temp_h*256+temp_l;
if(sel_10==1 && temp<=5000 && gate==4)
{
sel_x(1);
a1=2;
a2='K';
delay_1(del);
}
temp=temp_h*256+temp_l;
if(sel_1==1 && temp<=5000 && gate==4)
{
gate=40;
a1=1;
a2='K';
delay_1(del);
}
//---------------------------------------------------
temp=temp_h*256+temp_l;
if(sel_1==1 && temp>50010 && gate==40)
{
gate=4;
a1=2;
a2='K';
delay_1(del);
}
temp=temp_h*256+temp_l;
if(sel_1==1 && temp>50010 && gate==4)
{
sel_x(10);
a1=0;
a2='M';
delay_1(del);
}
temp=temp_h*256+temp_l;
if(sel_10==1 && temp>50010 && gate==4)
{
sel_x(100);
a1=1;
a2='M';
delay_1(del);
}
if(temp>50000)
goto reset;
dis_mod(temp,a1,a2);
//---------------------------------------------------
}
exit: TMOD=0x00; //T1 做门控计数
ET0=0;
EA=0;
TR0=0;
TR1=0;
p3_5=0;
delay_1(10);
keyfuncindex=0;
d0();
}
//--------------------------------------------------------------------
//模块:PWM.C
//功能:PWM解码模块
//晶振:24.000MHz
//芯片: STC12C5412AD
//版本:V1.0.0
//设计:魏广寅
//日期:2007.4.10
#include "stc12c5412ad.h"
#define uchar unsigned char
#define uint unsigned int
#define CNT 32
//--------------------------------------------------------------------
extern uchar keyfuncindex;
extern void d2(void);
extern void lcd_init(void);
extern void dis_one_char(uchar x,uchar y,uchar asc_num,bit b_flag);
extern void dis_one_zi(uchar x_add,uchar y_add,uchar code *po,bit back_flag,bit char_moudle);
extern void delay(uint time);
extern void delay_1(uchar time);
extern void dis_cls(void);
extern uchar code tab[16];
uchar data value_h[CNT];
uchar count=0;
sbit key0=P3^0;
sbit key1=P3^1;
//--------------------------------------------------------------------
void pwm_init()
{
TMOD=0x01;
TH0=0;
TL0=0;
IT0=1;
EX0=1;
EA=1;
}
//--------------------------------------------------------------------
void clk() interrupt 0
{
if(TH0==TL0 && TL0==0)
{
TR0=1;
}
else
{
TR0=0;
value_h[count]=TH0;
TH0=0;
TL0=0;
TR0=1;
count++;
if(count==CNT-1)
{
EX0=0;
count=0;
TH0=0;
TL0=0;
TR0=0;
}
}
}
//--------------------------------------------------------------------
void bin_to_hex(uchar x,uchar y,uchar bin)
{
uchar b_h,b_l;
b_h=bin & 0xf0;
b_h>>=4;
b_h=tab[b_h];
b_l=bin & 0x0f;
b_l=tab[b_l];
y*=2;
dis_one_char(x,y,b_h,1);
dis_one_char(x,y+1,b_l,1);
}
//--------------------------------------------------------------------
void pwm()
{
uchar i=0,x=0,y=0,ii;
pwm_init();
dis_cls();
while(1)
{
for(x=0;x<4;x++)
{
for(y=0;y<8;y++)
{
ii=value_h[i++];
bin_to_hex(x,y,ii);
}
}
i=0;
key0=1;
key1=1;
delay_1(5);
if(key0==0 || key1==0)
{
for(i=0;i<32;i++)
{
value_h=0;
}
goto exit;
}
}
exit:for(i=0;i<32;i++)
{
value_h=0;
}
TMOD=0x00;
TH0=0;
TL0=0;
count=0;
EX0=0;
EA=0;
TR0=0;
TR1=0;
keyfuncindex=2;
d2();
}
//--------------------------------------------------------------------
//模块:LCD12864_Driver_New.C
//功能:液晶显示器驱动模块
//晶振:24.000MHz
//芯片: STC12C5412AD
//版本:V1.0.0
//设计:魏广寅
//日期:2007.4.10
#include"STC12C5412AD.H"
#include"intrins.h"
#define dat P2
#define uchar unsigned char
#define uint unsigned int
//--------------------------------------------------------------------
sbit cs2=P1^3;
sbit cs1=P1^2;
sbit en=P3^7;
sbit rw=P1^0;
sbit di=P1^1;
//--------------------------------------------------------------------
uchar code ASC_20[16] = {
/* CHAR_20 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
uchar code ASC_21[16] = {
/*! CHAR_21 */
0x00,0x00,0x00,0xF8,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00};
uchar code ASC_22[16] = {
/*" CHAR_22 */
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
uchar code ASC_23[16] = {
/*# CHAR_23 */
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,
0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00};
uchar code ASC_24[16] = {
/*$ CHAR_24 */
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,
0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00};
uchar code ASC_25[16] = {
/*% CHAR_25 */
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,
0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00};
uchar code ASC_26[16] = {
/*& CHAR_26 */
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,
0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10};
uchar code ASC_27[16] = {
/*` CHAR_60 */
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
uchar code ASC_28[16] = {
/*( CHAR_28 */
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,
0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00};
uchar code ASC_29[16] = {
/*) CHAR_29 */
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,
0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00};
uchar code ASC_2a[16] = {
/** CHAR_2A */
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00};
uchar code ASC_2b[16] = {
/*+ CHAR_2B */
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00};
uchar code ASC_2c[16] = {
/*' CHAR_27 */
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
uchar code ASC_2d[16] = {
/*- CHAR_2D */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01};
uchar code ASC_2e[16] = {
/*. CHAR_2E */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00};
uchar code ASC_2f[16] = {
/*/ CHAR_2F */
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -