中微SC8p8022单片机双色无级调光单片机解密
- 单片机解密#include <sc.h>
- 单片机解密#include "Touch_Kscan_Library.h"
- volatile unsigned int pwm_duty,pwm_duty1,pwm_duty2,num;
- volatile unsigned char MainTime,touch_count = 0;
- volatile bit B_MainLoop,state=0;
- volatile unsigned int Time;
- void delay(int count) {
- for (int i = 0; i < count; i++) {
- for (int j = 0; j < 100; j++) {
- }
- }
- }
- //系统初始化
- void Init_System()
- {
- asm("nop");
- asm("clrwdt");
- INTCON = 0; //禁止中断
- OSCCON = 0X72; //配置振荡为8M
- OPTION_REG = 0;
-
- PORTB = 0;
-
- PIE1 = 2;
-
- PR2 = 250; //8M下将TMR2设置为125us中断
- //TRISB=0B00010100;
- TRISB=0;
- PWMCON0=0;
- PWMTL=0XEF;
- PWMT4L=0XEF;
- PWMTH=0B00001111;
-
- PWMD23H=00;
- PWMD3L=0X0F;
- PWMD4L=0X0F;
-
-
- PWMIF=0;
- PWMCON0 &= ~(0b00011000);
-
- T2CON = 4; //使能定时器2
- INTCON = 0XC0; //使能中断
- }
- void Refurbish_Sfr()
- {
- //刷新中断相关控制寄存器
- PIE1 = 2;
- PR2 = 250;
- INTCON = 0XC0;
- if (4 != T2CON)
- T2CON = 4;
- }
- void set_pwm_duty_cycle(unsigned int pwm3_duty, unsigned int pwm4_duty)
- {
-
-
-
- pwm3_duty=pwm3_duty/4;
- pwm4_duty=pwm4_duty/4;
- // 写入PWM3占空比(8位)
-
- PWMD23H = ((pwm3_duty >> 8) & 0x03)<<4; // 高2位
- PWMD3L = pwm3_duty&0xFF ; // 低8位
- // 写入PWM4占空比(10位)
- PWMTH = ((pwm3_duty >> 8) & 0x03)<<4;
- PWMD4L = pwm4_duty&0xFF;
- PWMCON0=0B00011000;
-
-
-
-
-
- }

芯片解密