51单片机—实时时钟

该博客介绍了51单片机中实时时钟的配置和中断处理,通过示例展示了如何解析红外遥控信号,并对接收到的信号进行处理。文章包含定时器初始化、中断服务函数和红外数据处理函数的详细代码。
摘要由CSDN通过智能技术生成
#include <reg52.h>
#include "./lcd/lcd.h"
#include "./delay/delay.h"

unsigned int irtime;
bit startflag = 0;
unsigned char irdata[33] ;
bit irok;
unsigned char ircode[4];

unsigned char ir_process()
{
		unsigned char i,j,k;
		unsigned char temp;
		k = 1;
		for(j = 0; j < 4; j++)
		{
				for(i = 0; i < 8; i++)
				{
						temp >>= 1;
						if(irdata[k] > 6)
						{
								temp += 0x80;
						}
						k++;
				}
				ircode[j] = temp;
		}
		if((ircode[0]+ircode[1] == 0xff) && (ircode[2]+ircode[3] == 0xff))
		{
				switch(ircode[2])
				{
						case 0x16: return 0;
						case 0x0c: return 1;
						case 0x18: return 2;
						case 0x5e: return 3;
						case 0x08: return 4;
						case 0x1c: return 5;
						case 0x5a: return 6;
						case 0x42: return 7;
						case 0x52: return 8;
						case 0x4a: return 9;
						case 0x45: return 10;
		
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值