zoukankan      html  css  js  c++  java
  • 模拟红外协议C程序——接收模块

    目的:方便程序的调试,提供效率,减少工作累,可以不在线调试编程时显示实时数据,特别产品不带显示的或者MCU是OPT的,有很大的帮助。

    过程:将要看的数据发送出来,另一个板(一个带有显示的就OK了,显示就看个人的了,我之前用12864显示,后面坏了,就用4位数码管了)接收显示出来。

    资源:通讯口只要2个IO(接收一个,发送一个),定时器2个(接收一个,发送一个)。

    此篇是本人的接收模块,由于手头没有什么显示板,只有一个中颖的,带有4为数码管,就用此板作模拟接收。

    此接收发送模块已经使用3年,一点问题都没有的哦!!!

    如要沟通,请联系QQ:448704229

    以下是接收模块:

    //REMOTE 为接收IO ,设置为输入
    
    static uint8 rx_ram0=0;
    static uint8 rx_ram1=0;
    static  uint8 rx_ram2=0;
    static  uint8	bits_count=0;
    
    static  uint8	tx_ram0=0;
    static  uint8	tx_ram1=0;
    static  uint8	tx_ram2=0;
    static  uint8	temp2=0;
    static  uint8	us100_timer=0;
    
    bit	f_endcode=0;
    bit	B_nextbit=0;
    bit	send_enable_flag=0;
     uint8	temp1=0;
      uint8	temp=0;
    void recievr_ird(void)
    {
    
    
       	static uint8 TN=0;
    		static uint8 REMOTE_NUM=0;
      if(TN<=200)
    	  {
    	  	  TN++;
    	   }
    		  if(!F_REMOTE)
    		  {
    		  	if(REMOTE)
    			{
    				if(!F_RISE_YK)
    				{
    					 F_RISE_YK=1;
    					 if(F_YK_FIRST)
    					 {
    					 	 if(TN>=5)
    						 {
    						 //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    						 	
    						 }
    						 else
    						 {
    						 	 TN=0;
    						 }
    					 }
    					 else
    					 {
    					 	if(TN>=40)
    						{
    						 //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    						}
    						else
    						{
    						   	if(TN>=20)
    							{
    								F_YK_FIRST=1;
    								TN=0;
    								REMOTE_NUM=0;
    								tx_ram0=0;
    							
    							}
    							else
    							{ //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    							}
    
    						}
    					 }
    				}
    			
    			}
    			else
    			{
    					if(F_RISE_YK)
    					{
    						 F_RISE_YK=0;
    						 if(F_YK_FIRST)
    						 {
    						 	 if(!F_YK_SECOND)
    							 {
    							  	if(TN>=18)
    								{
    								  //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    								}
    						
    								else
    								{
    								   	if(TN>=12)
    									{
    										F_YK_SECOND=1;
    										TN=0;
    										REMOTE_NUM=0;
    										tx_ram0=0;
    									
    									}
    									else
    									{
    									   //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    									}
    
    								}
    							 }
    							 else
    							 {
    				   
    								 tx_ram2=tx_ram2>>1;
    
    								if(tx_ram1&0x01)
    								{
    									 tx_ram2=tx_ram2|0x80;
    								}
    								else
    								{
    									 tx_ram2=tx_ram2&0x7f;
    								}
    
    								  tx_ram1=tx_ram1>>1;
    
    								if(tx_ram0&0x01)
    								{
    									 tx_ram1=tx_ram1|0x80;
    								}
    								else
    								{
    									 tx_ram1=tx_ram1&0x7f;
    								}
    								 tx_ram0=tx_ram0>>1;
    
    
    								 	if(TN>=12)
    								{
    								  //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    	
    								}
    						
    								else
    								{
    								   	if(TN>=6)
    									{
    									
    									  tx_ram0|=0x80;	  ///
    									  B_nextbit=1;
    									}
    									else
    									{
    											if(TN<2)
    										{
    									 //EER
    								   	 		 //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    	
    										}
    										else
    										{
    											tx_ram0&=0x7f;	  ///
    											B_nextbit=1;
    										}
    									 
    									}
    								}
    							 }
    						 }
    						 else
    						 {
    						  //EER
    						    TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    						 }
    					 }
    			}
    		  
    		  }
    if(B_nextbit)//移位操作//<intrins.h> temp = _cror_(temp,1);_rcl
    {
    	B_nextbit=0;
      TN=0;
    	REMOTE_NUM++;
    	
    	if(REMOTE_NUM>=24)
    	{
    		rx_ram0=tx_ram2;
    	   F_REMOTE=1;
        	rx_ram1=tx_ram1;
    		rx_ram2=tx_ram0;
    	F_REMOTE=0;
    
    	 TN=0;
    	  						tx_ram0=0;
    						    REMOTE_NUM=0;
    							F_YK_FIRST=0;
    							F_YK_SECOND=0;
    	}
    }
    }


     

  • 相关阅读:
    day044CSS相关属性之盒子模型、float浮动、overflow溢出属性、position定位
    day045JavaScript的介绍、数据类型
    day043 前端之CSS引入方式、选择器、相关属性
    day042前端之HTML
    攻防世界wp--web simple_php
    hackbar的谷歌和火狐破解方式
    攻防世界wp--web cookie
    攻防世界wp-misc stegano
    攻防世界wp-misc 功夫再高也怕菜刀
    攻防世界wp-misc base64stego
  • 原文地址:https://www.cnblogs.com/riskyer/p/3263243.html
Copyright © 2011-2022 走看看