STC89C52RC单片机制作可调程序芯片解密
芯片解密单片机必须是52rc不能用60s2
*/
#include"main.h"
#include"peizhi.h"
#include"smg.h"
#include"eeprom.h"
sfr WDT_CONTR=0XE1;
unsigned char HighRH = 0; //高电平重载值的高字节
unsigned char HighRL = 0; //高电平重载值的低字节
unsigned char LowRH = 0; //低电平重载值的高字节
unsigned char LowRL = 0; //低电平重载值的低字节
/***********************按键定义**********************************/
bit d1 = 1;
bit d2 = 1;
bit d3 = 1;
uint8 ci;
uint8 ca = 0;
uint8 ca1 = 0;
uint16 cb = 0;
void key(); //按键函数声明
void ConfigPWM(unsigned int fr, unsigned char dc); //频率和占空比调节函数
void main()
{
bit q1 = 1;
bit q2 = 1;
bit q3 = 1;
ca = EEPROMReadByte(0);
cb = EEPROMReadByte(1)*255+EEPROMReadByte(2);
EA = 1; //开总中断
peizhit1(1); //配置T0定时2ms
while(1)
{
ConfigPWM(cb, ca); //频率100Hz,占空比10%
if(d1 != q1)
{
q1 = d1;
if(d1 == 0)
{
ca1++;
if(ca1 >= 2)
{
ca1 = 0;
}
}
}
if(ca1 == 1)
{
if(d2 != q2)
{
q2 = d2;
if(d2 == 0)
{
ca++;
EEPROMSectorErase(0);
EEPROMWriteByte(0,ca);
EEPROMWriteByte(2,cb);
EEPROMWriteByte(1,cb>>8);
if(ca >= 99)
{
ca = 99;
}
}
}
if(d3 != q3)
{
q3 = d3;
if(d3 == 0)
{
if(ca>0)
{
ca--;
EEPROMSectorErase(0);
EEPROMWriteByte(0,ca);
EEPROMWriteByte(2,cb);
EEPROMWriteByte(1,cb>>8);
}
}
}
}
if(ca1 == 0)
{
if(d2 == 0)
{
cb++;
EEPROMSectorErase(0);
EEPROMWriteByte(0,ca);
EEPROMWriteByte(2,cb);
EEPROMWriteByte(1,cb>>8);
if(cb >= 200)
{
cb = 200;
}
}

芯片解密