最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

TC9012芯片红外解码程序

来源:动视网 责编:小OO 时间:2025-10-04 05:25:48
文档

TC9012芯片红外解码程序

//使用12M晶振适用于TC9012芯片,其他芯片请自行更改解码时序#include#include#include////////////////////////////////////////////////#defineTURE1#defineFALSE0////////////////////////////////////////////////sbitIR=P3^2;//红外接口标志unsignedcharconstdofly[]={0x3f,0x06,0x5b,0x4f,0x66
推荐度:
导读//使用12M晶振适用于TC9012芯片,其他芯片请自行更改解码时序#include#include#include////////////////////////////////////////////////#defineTURE1#defineFALSE0////////////////////////////////////////////////sbitIR=P3^2;//红外接口标志unsignedcharconstdofly[]={0x3f,0x06,0x5b,0x4f,0x66


//使用12M晶振 适用于TC9012芯片,其他芯片请自行更改解码时序

#include

#include

#include

////////////////////////////////////////////////

#define TURE 1

#define FALSE 0

////////////////////////////////////////////////

sbit IR=P3^2;//红外接口标志

unsigned char const dofly[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

////////////////////////////////////////////

unsigned char irtime;//红外用全局变量

bit irpro_ok,irok;

unsigned char IRcord[4];

unsigned char irdata[33];

//////////////////////////////////////////////

void Delay(unsigned char mS);

void Ir_work(void);

void Ircordpro(void);

//////////////////////////////////////////////////////////////////

void tim0_isr (void) interrupt 1 using 1//定时器0中断服务函数

{

irtime++;

}

///////////////////////////////////////////////////////////////////////

void ex0_isr (void) interrupt 0 using 0//外部中断0服务函数

{

static unsigned char i;

static bit startflag;

if(startflag)

{

if(irtime<42&&irtime>=33)//引导码 TC9012的头码

i=0;

irdata[i]=irtime;//一次存储32位电平宽度

irtime=0;

i++;

if(i==33)

{

irok=1;

i=0;

}

}

else

{irtime=0;startflag=1;}

}

////////////////////////////////////////////////////////////////////

void TIM0init(void)//定时器0初始化

{

TMOD=0x02;//定时器0工作方式2,TH0是重装值,TL0是初值

TH0=0x00;//reload value

TL0=0x00;//initial value

ET0=1;//开中断

TR0=1;

}

///////////////////////////////////////////////////////////////////

void EX0init(void)

{

IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)

EX0 = 1; // Enable EX0 Interrupt

EA = 1;

}

/****************************************************************/

/******************************************************************/

void Ir_work(void)//红外键值散转程序

{

switch(IRcord[2])//判断第三个数码值

{

case 0:P0=dofly[1];break;//1 显示相应的按键值

case 1:P0=dofly[2];break;//2

case 2:P0=dofly[3];break;//3

case 3:P0=dofly[4];break;//4

case 4:P0=dofly[5];break;//5

case 5:P0=dofly[6];break;//6

case 6:P0=dofly[7];break;//7

case 7:P0=dofly[8];break;//8

case 8:P0=dofly[9];break;//9

}

irpro_ok=0;//处理完成标志

}

/*****************************************************************/

void Ircordpro(void)//红外码值处理函数

{

unsigned char i, j, k;

unsigned char cord,value;

k=1;

for(i=0;i<4;i++)//处理4个字节

{

for(j=1;j<=8;j++) //处理1个字节8位

{

cord=irdata[k];

if(cord>7)//大于某值为1

{

value=value|0x80;

}

else

{

value=value;

}

if(j<8)

{

value=value>>1;

}

k++;

}

IRcord[i]=value;

value=0;

} irpro_ok=1;//处理完毕标志位置1

}

/////////////////////////////////////////////////////////////////

void main(void)

{

EX0init(); // Enable Global Interrupt Flag

TIM0init();//初始化定时器0

P2=0x00;//1位数码管全部显示

while(1)//主循环

{

if(irok)

{

Ircordpro();//码值处理

irok=0;

}

if(irpro_ok)//step press key

{

Ir_work();//码值识别散转

}

}

}

文档

TC9012芯片红外解码程序

//使用12M晶振适用于TC9012芯片,其他芯片请自行更改解码时序#include#include#include////////////////////////////////////////////////#defineTURE1#defineFALSE0////////////////////////////////////////////////sbitIR=P3^2;//红外接口标志unsignedcharconstdofly[]={0x3f,0x06,0x5b,0x4f,0x66
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top