找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 272|回复: 1
打印 上一主题 下一主题
收起左侧

一款基于锦锐单片机遥控接收1527码的软解码程序

[复制链接]
跳转到指定楼层
楼主
ID:66086 发表于 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))                 //非学习状态
  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, 下载次数: 12)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:712493 发表于 2024-3-25 21:42 | 只看该作者
楼主,调试命令放在那个文件?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表