• <table id="4yyaw"><kbd id="4yyaw"></kbd></table>
  • <td id="4yyaw"></td>
  • 發布時間:2020-10-05 22:02 原文鏈接: 淺析紅外遙控解碼(三)

    void UART_Initial();

    void DELAY_Us(unsigned int Us)

    {

    unsigned int x;

    for(x = 0; x <= (Us/200-1); x++);

    }

    void DELAY_Ms(unsigned int Ms)

    {

    unsigned int x,y;

    for(x = 0; x <= (Ms-1); x++)

    {

    for(y = 0; y <= 120; y++);

    }

    }

    void main()

    {

    unsigned char i;

    UART_Initial();

    IR_Out = 1;

    while(1)

    {

    START_Flag = START_Judge();

    BOOT_REPEATING_CODE_Flag = BOOT_REPEATING_CODE_Judge();

    if ( START_Flag && !BOOT_REPEATING_CODE_Flag )

    {

    for(i =0;i<4; i++)

    {

    B0 = H_L_LEVEL_Judge();

    B1 = H_L_LEVEL_Judge();

    B2 = H_L_LEVEL_Judge();

    B3 = H_L_LEVEL_Judge();

    B4 = H_L_LEVEL_Judge();

    B5 = H_L_LEVEL_Judge();

    B6 = H_L_LEVEL_Judge();

    B7 = H_L_LEVEL_Judge();

    DATA[i] = TEMP_BIT;

    }

    for(i =0;i<4; i++)

    {

    SBUF = DATA[i];

    while( TI == 0 );

    TI = 0;

    }

    }

    }

    }

    void UART_Initial()

    {

    SCON = 0x50;            // SCON: 模式 1, 8-bit UART, 使能接收

    TMOD |= 0x20;           // TMOD: timer 1, mode 2, 8-bit reload

    TH1 = 0xFD;             // TH1: reload value for 9600 baud @

    // 11.0592MHz

    TR1 = 1;                // TR1: timer 1 run

    EA = 0;                 // 關閉總中斷

    ES = 0;                 // 關閉串口中斷

    }

    }

    注

    1、紅外遙控的編碼不只NEC,還有很多也有廣泛應用如RC-5,RC-6等。

    2、上面的代碼所用指令是STC 89C52單片機,如需用其它芯片請另行更改。


  • <table id="4yyaw"><kbd id="4yyaw"></kbd></table>
  • <td id="4yyaw"></td>
  • 调性视频