欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 6908|回復(fù): 3
收起左側(cè)

紅外接收程序問題!!幫忙看看

[復(fù)制鏈接]
ID:8704 發(fā)表于 2009-6-5 11:56 | 顯示全部樓層 |閱讀模式

#include <reg52.h>
#include <lcd.h>
#include <epprom.h>

unsigned int temp_low_pulse1;
unsigned int temp_low_pulse0;
unsigned int temp_high_pulse1;
unsigned int temp_high_pulse0;
unsigned int count;
unsigned char write_enable;

sbit led8=P0^7;
sbit key=P0^0;
sbit key1=P0^1;
sbit key2=P0^2;


/*********      延時(shí)1S     ******************************************/
void delay_1s()
{
 unsigned int i,j;
 for(i=5;i>0;i--)
  for(j=110;j>0;j--);
}


void initial()
{
 EA=1; //開啟總中斷
 EX1=1; //開啟外部中斷1
 IT1=1; //外部中斷1為下降沿有效
 TMOD=0x19; //定時(shí)器1,2 方式為1,且T0 GATE位有效
 TH0=0x00;
 TL0=0x00;
 TH1=0x00;
 TL1=0x00;
 count=0;
}

void main()
{
 unsigned char temp,temp_ge,temp_shi,temp_bai,num_ge,num_shi,num_bai,num_qian;
 unsigned int  count_qian,count_bai,count_shi,count_ge,num;
 initial();
 init();
 lcd_int();


 num=0;
 while(1)
 {
  if(key==0)
  {

   num++;
   if(num==2048)
   num=0;
   while(!key);
  }
  if(key1==0)
  {
  

   if(num==0)
    num=2048;
     num--;
   while(!key1);
  }
 if(count>=2048)
  count=0;
 temp=read_add(num);
 temp_bai=temp/100;
 temp_shi=temp%100/10;
 temp_ge=temp%10;
 num_qian=num/1000; 
 num_bai=num%1000/100;
 num_shi=num%100/10;
 num_ge=num%10;
 count_qian=count/1000;
 count_bai=count%1000/100;
 count_shi=count%100/10;
 count_ge=count%10;
 
 write_com(0x80); 
 write_date(0x30+temp_bai);
 write_com(0x81); 
 write_date(0x30+temp_shi);
 write_com(0x82); 
 write_date(0x30+temp_ge);
 write_com(0x84); 
 write_date(0x30+num_qian);
 write_com(0x85); 
 write_date(0x30+num_bai);
 write_com(0x86); 
 write_date(0x30+num_shi);
 write_com(0x87); 
 write_date(0x30+num_ge);
 write_com(0x89); 
 write_date(0x30+count_qian);
 write_com(0x8a); 
 write_date(0x30+count_bai);
 write_com(0x8b); 
 write_date(0x30+count_shi);
 write_com(0x8c); 
 write_date(0x30+count_ge);
 if (write_enable==1)
 {
 write_add(count,5);   //將紅外信號(hào)的低電平的值寫入儲(chǔ)存器COUNT地址內(nèi)
 delay_1s();
 write_add(count+1,6);   //將紅外信號(hào)的低電平的值寫入儲(chǔ)存器COUNT+1地址內(nèi) 
 delay_1s();
 write_add(count+2,7);  //將紅外信號(hào)的高電平的值寫入儲(chǔ)存器COUNT+2地址內(nèi)
 delay_1s();
 write_add(count+3,8);  //將紅外信號(hào)的高電平的值寫入儲(chǔ)存器COUNT+3地址內(nèi)
 delay_1s();
 write_enable=0;
 }
 }


}

void int1() interrupt 2
{
 
  
    EX1=0;          //關(guān)外部中斷1
 TR0=0;          //關(guān)閉定時(shí)器0
 TR1=0;          //關(guān)閉定時(shí)器1
 temp_low_pulse1=TH1-TH0;     //將TH1減去TL0的值(即紅外信號(hào)的低電平)賦予temp_low_pulse1
 temp_low_pulse0=TL1-TL0;         //將TL1減去TL0的值(即紅外信號(hào)的低電平)賦予temp_low_pulse0
 temp_high_pulse1=TH0;      //將TH0值(即紅外信號(hào)的高電平值)賦予temp_high_pulse1
 temp_high_pulse0=TL0;      //將TL0值(即紅外信號(hào)的高電平值)賦予temp_high_pulse0
 write_enable=1;
 TH0=0x00;         //TH0清零
 TL0=0x00;         //TL0清零
 TH1=0x00;         //TH1清零
 TL1=0x00;         //TL1清零
 TR0=1;          //啟動(dòng)定時(shí)器0
 TR1=1;          //啟動(dòng)定時(shí)器1
 led8=!led8;
 count=count+4; 
 EX1=1;          //開外部中斷1
 

}

 

本人編寫了一個(gè)紅外接收的程序,紅外接收管接收端接單片機(jī)中斷1,接收的紅外波形以后,開啟T0,T1定時(shí)器,對(duì)紅外波形的高低電平及時(shí),其中中斷下降沿開啟T1計(jì)時(shí),電平升高后開啟T0計(jì)時(shí),T1-T0的時(shí)間就是紅外波形的低電平時(shí)間,我利用AT24C16芯片保存定時(shí)時(shí)間,根據(jù)寫的程序,在兩次中斷間隙時(shí)間過短了,沒有足夠的時(shí)間寫進(jìn)存儲(chǔ)芯片,怎么解決啊?

 

回復(fù)

使用道具 舉報(bào)

ID:8704 發(fā)表于 2009-6-10 11:34 | 顯示全部樓層

回復(fù)

使用道具 舉報(bào)

ID:16415 發(fā)表于 2009-8-28 11:32 | 顯示全部樓層
 頂一下,我也在弄紅外呢呵呵
回復(fù)

使用道具 舉報(bào)

ID:16651 發(fā)表于 2009-8-28 20:08 | 顯示全部樓層
不知道你的問題解決了嗎  我前一段時(shí)間也謝了一個(gè)簡單的紅外程序  傳到http://sjcxlab.5d6d.com/thread-46-1-1.html  這里了  有興趣的可以去看一下~~~~
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表