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

📄 lesson6.c

📁 单片机设计存档
💻 C
字号:
#include<reg52.h>
#include<intrins.h>
#include"init.h"
#include"1602.h"
#include"ds1302.h"
#include"display.h"
#include"clock_reda.h"
#include"keycan.h"
#include"18b20.h"


void clock_reda()
{
	week  =readbyte(0x8b);   //读星期
	year  =readbyte(0x8d);   //读年
	mouth =readbyte(0x89);   //读月
	day   =readbyte(0x87);   //读日
	hour  =readbyte(0x85);   //读小时
	minute=readbyte(0x83);   //读分钟
	sec   =readbyte(0x81);	 //读秒 
}

void main()
{
	init();//定义初始化
	init_1602();//1602初始化
	init_ds1302();//1302初始化
	while(1)
	{
		if(flag==0)
		{
			clock_reda();//读取时钟
		}
		keycan();    //扫描键盘
	}
}

void time0() interrupt 1
{
	TH0=(65535-50000)/256;
	TL0=(65535-50000)%256;
	num1++;
	if(num1==18)
	 {
	 	num1 =0;
		temp =readtemperture();
		 if(temp&0x8000)
		 {
		     TempData[0]='-';//负号标志
		     temp=~temp;  // 取反加1
			 temp +=1;
	     }
		  else
		     TempData[0]='+';
		
		     TempH=temp>>4;
		     TempL=temp&0x0F;
		     TempL=TempL*6/10;//小数近似处理
		    	
		    if((TempH/100==0)&&((TempH%100)/10==0))//消隐
			  TempData[1]='H';
			else
		     TempData[1]=(TempH%100)/10; //十位温度

		     TempData[2]=(TempH%100)%10; //个位温度
		     TempData[3]=TempL;
		 	
			write_cmd(0x80+0x49);       //显示温度
			write_dat(TempData[0]);		
			write_dat(TempData[1]+'0');	
			write_dat(TempData[2]+'0');	
			write_dat('.');
			write_dat(TempData[3]+'0');	
			write_dat(0xdf);
			write_dat('C');	
	 }
}

⌨️ 快捷键说明

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