找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1817|回復: 1
收起左側

一款基于錦銳單片機遙控接收1527碼的軟解碼程序

[復制鏈接]
ID:66086 發(fā)表于 2024-3-25 16:08 | 顯示全部樓層 |閱讀模式
一款基于錦銳單片機遙控接收1527碼的軟解碼程序

  1. #ifndef _MAIN_C_
  2. #define _MAIN_C_
  3. /*********************************************************************************************************************/
  4. #include "ca51f_config.h"
  5. #include "includes\ca51f3sfr.h"
  6. #include "includes\ca51f3xsfr.h"
  7. #include "includes\gpiodef_f3.h"

  8. #include "Library\includes\delay.h"
  9. #include "Library\includes\uart.h"
  10. #include "Library\includes\system_clock.h"
  11. #include "Library\Includes\rtc.h"       
  12. #include "Library\Includes\pwm.h"       
  13. #include "includes\system.h"
  14. #include "Library\includes\adc.h"
  15. #include "Library\includes\wdt.h"

  16. /*********************************************************************************************************************/
  17. #include "TS_Lib\Includes\ts_configuration.h"
  18. #include "TS_Lib\Includes\ts_def.h"
  19. #include "TS_Lib\Includes\ts_api.h"
  20. #include "TS_Lib\Includes\ts_service.h"
  21. /*********************************************************************************************************************/       
  22. #include "tm1628.h"
  23. #include "time.h"
  24. //#include "74hc595.h"

  25. unsigned char read_inner_trim(void)                               
  26. {
  27.         unsigned char value;
  28.         FSCMD = 0x80;       
  29.         PTSH = 0x00;                               
  30.         PTSL = 0x24;      
  31.         FSCMD = 0x81;                                               
  32.         value = FSDAT;
  33.         FSCMD = 0;
  34.         return value;
  35. }
  36. void SystemInit(void)
  37. {
  38. #ifdef LVD_RST_ENABLE
  39.         LVDCON = 0xE1;        //設置LVD復位電壓為2V
  40. #endif
  41. #if (SYSCLK_SRC == PLL)
  42.         Sys_Clk_Set_PLL(PLL_Multiple);       
  43. #endif
  44. #ifdef UART0_EN
  45.         Uart0_Initial(UART0_BAUTRATE);
  46. #endif
  47. #ifdef UART1_EN
  48.         Uart1_Initial(UART1_BAUTRATE);
  49. #endif

  50. #if (RTC_CLK_SELECT == IRCL)
  51. //看門狗時鐘源為IRCL
  52.         CKCON |= ILCKE;                                                                                                                                         //使能IRCL
  53.         WDCON  = WDTS(WDTS_IRCL) | WDRE(WDRE_reset);           //設置看門狗時鐘源為ILCKE,模式為復位模式
  54. #elif (RTC_CLK_SELECT == XOSCL)       
  55.         CKCON |= XLCKE;
  56.         while(!(CKCON & XLSTA));
  57.         WDCON  = WDTS(WDTS_XOSCL) | WDRE(WDRE_reset);   //設置看門狗時鐘源為XOSCL,模式為復位模式
  58. #endif
  59.         WDVTHH = 0;                                                                                                                                                         //看門狗復位閾值高八位設置 當前值為5s       
  60.         WDVTHL = 75;                                                                                                                                                 //看門狗復位閾值低八位設置
  61.         WDFLG = 0xA5;       
  62.        
  63.        
  64.         ADCFGH = (ADCFGH&0xC0) | VTRIM(read_inner_trim());        //加載ADC內部基準校準值
  65. }

  66. void main(void)
  67. {       
  68.         unsigned char i;
  69.         SystemInit();       
  70.         EA = 1;
  71.         TS_init();
  72.         Timer1_mode2_Init();
  73. //        Uart0_PutChar(0xab);
  74.   user_EEprom_init();
  75.         Read_Buff();
  76.         Out0=0;
  77.         Out1=0;
  78.         Out2=0;
  79.         Out3=0;
  80.         while(1)
  81.         {
  82.                 TS_Action();
  83.                 Study_Key();
  84.                 Study_RF();
  85.                 if(rf_Ok&&(!Study_flag))                 //非學習狀態(tài)
  86.                 {
  87.                         rf_Ok = 0;
  88.                         KeyTo1527();                                 //轉換數據
  89.                         for(i=0;i<KEY_num;i++)
  90.                         {
  91.                                 if((RfBuff[0]==key_number[i*3+1])&&(RfBuff[1]==key_number[i*3+2])&&(RfBuff[2]==key_number[i*3+3]))
  92.                                 {
  93. //                                        VT = 1;       
  94.                                         Hold_Time = 0;
  95.                                         if(!LM)                                                                                                //點動
  96.                                         {
  97.                                                 if((RfBuff[3]&0x10) == 0x10) Out0 = 0;
  98.                                                 if((RfBuff[3]&0x20) == 0x20) Out1 = 0;
  99.                                                 if((RfBuff[3]&0x40) == 0x40) Out2 = 0;
  100.                                                 if((RfBuff[3]&0x80) == 0x80) Out3 = 0;
  101.                                                 Uart0_PutChar(RfBuff[3]);                                               
  102.                                         }
  103.                                         else if(LM&&!Decod_Ok)                                                                //自鎖
  104.                                         {
  105.                                                 if((RfBuff[3]&0x10) == 0x10) Out0 = !Out0;
  106.                                                 if((RfBuff[3]&0x20) == 0x20) Out1 = !Out1;
  107.                                                 if((RfBuff[3]&0x40) == 0x40) Out2 = !Out2;
  108.                                                 if((RfBuff[3]&0x80) == 0x80) Out3 = !Out3;
  109. //            Uart0_PutChar(RfBuff[3]);                                                       
  110.                                         }
  111.                                         Decod_Ok = 1;
  112.                                         break;       
  113.                                 }       
  114.                         }                       
  115.                 }       

  116.         }
  117.        
  118. }
  119. #endif
復制代碼

原理圖: 無
仿真: 無
代碼: CA51F3_1527解碼程序.7z (97.79 KB, 下載次數: 18)

評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復

使用道具 舉報

ID:712493 發(fā)表于 2024-3-25 21:42 | 顯示全部樓層
樓主,調試命令放在那個文件?
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表