芯片解密,芯片破解,IC解密,单片机解密,MCU解密,STM解密

飞芯科技提供芯片解密,芯片破解,IC解密,单片机解密,MCU解密,STM解密逆向服务

松翰SN8F5703单片机PWM例程IC解密

  1. //-----------------------------------------------------------------------------
  2. //  FILE:   PWM3_Pulse.c
  3. //-----------------------------------------------------------------------------
  4. // IC解密
  5. //
  6. //  The program is an example of PWM3 one pulse function to implement it.
  7. //   
  8. //  PW3 pulse decription:
  9. //      1. when PW3EN = 1 ,
  10. //         PWM3 will output One Pulse PWM and than PW3EN to be 0
  11. //
  12. //  The system clock frequency is IHRC 32MHz
  13. //
  14. //  Device:     SN8F5708
  15. //  Tool chain: KEIL C51 V9.50a
  16. //

  17. //-----------------------------------------------------------------------------
  18. // Includes
  19. //-----------------------------------------------------------------------------
  20. #include <SN8F5703.h>
  21. //-----------------------------------------------------------------------------
  22. // Global Variables
  23. //-----------------------------------------------------------------------------

  24. //-----------------------------------------------------------------------------
  25. // Function Prototypes
  26. //-----------------------------------------------------------------------------
  27. void PWM1PLS_Init(void);

  28. //-----------------------------------------------------------------------------
  29. // Main loop
  30. //-----------------------------------------------------------------------------
  31. void main(void)
  32. {
  33.         CLKSEL = 0x06;                                                                        // Fcpu = 32M/2 = 16M
  34.         CLKCMD = 0X69;                                
  35.         CKCON = 0X10;                                                                                // From = 8M
  36.         
  37.   WDTR = 0x5A;                                            // clear watchdog if watchdog enable
  38.         
  39.         P0 = 0;
  40.         P0M = 0;
  41.         P0UR = 0xFF;
  42.         
  43.         P1 = 0;
  44.         P1M = 0xC0;
  45.         P1UR = 0xFF;
  46.         
  47.         P2 = 0;
  48.         P2M = 0x3C;
  49.         P2UR = 0xFF;
  50.         
  51.         PWM1PLS_Init();                                         // init PWM1

  52.     while (1)
  53.                 {
  54.         WDTR = 0x5A;                                // clear watchdog if watchdog enable
  55.                         

  56.                 }
  57. }
  58. //-----------------------------------------------------------------------------
  59. //  Function:    void PWM1PLS_Init(void)
  60. //  Description:
  61. //      init PWM1 pulse
  62. //                                
  63. //-----------------------------------------------------------------------------
  64. void PWM1PLS_Init(void)
  65. {
  66.                 PW1CH = 0x11;
  67.         
  68.     PW1M |= 0x70;                                   // PW1 rate is Fhosc/1     PWM输出频率危(32/1)/256 = 125KHZ   PWM周期为8uS

  69.     PW1M |= 0x08;                                   // enable PWM11 output (PWCH11)
  70.     PW1M |= 0x04;                                   // enable PWM10 output (PWCH10)

  71. //    PW1M |= 0x01;                                 // enable PW1 pulse output function (PW1PO)

  72.     PW1YH = 0x00;
  73.     PW1YL = 0xFF;                                                // set PW1 cycle control    256

  74.     PW1DH = 0x00;
  75.     PW1DL = 0x3F;                                   // set PWM duty control   64     占空比25%

  76.     // the dead band control : B point > A point (Must)
  77.     PW1BH = PW1DH;
  78.     PW1BL = PW1DL;                                  // B point dead band control

  79.     PW1A = 0x00;                                    // A point dead band control

  80.           PW1M |= 0x80;                                   // Enable PWM output function (PW1EN)
  81. }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.taihedz.cn
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信