芯片解密单片机红外遥控直流电机调速系统的程序设计
- 芯片解密#include <reg51.h>
- 芯片解密#define uchar unsigned char
- 芯片解密#define uint unsigned int
- sbit RS=P2^6; //LCD引脚
- sbit RW=P2^5;
- sbit EN=P2^7;
- sbit IRIN=P3^2; //红外接口
- sbit PWM_Out=P1^0; //PWM输出引脚
- uchar tab[]={"IR-CODE:00H"};
- unsigned char IrValue[6];
- unsigned char Time;
- unsigned char PWM_Cnt,PWM_Duty; //PWM_cnt : PWM周期变量 0~10; PWM_Duty: 占空比变量0~10
- void System_Init();
- void Delay_Ms(unsigned int x);
- void delayms(uint ms)
- {
- uint i,j;
- for (i=ms;i>0;i--)
- for(j=0;j<124;j++);
- }
- void lcdwc(uchar com)//写入命令
- {
- RS=0; //选择写入命令
- RW=0; //选择写入
- EN=0; //使能清零
- P0=com; //由于4位的接线是接到P0口的高四位,所以传送高四位不用改
- delayms(5);
- EN=1; //写入时序
- delayms(5);
- EN=0;
- P0=com<<4;//发送低四位
- delayms(5);
- EN= 1; //写入时序
- delayms(5);
- EN= 0;
- }
- void lcdwd(uchar dat)//写入数据
- {
- RS=1; //选择写入数据
- RW=0; //选择写入
- EN=0; //使能清零
- P0=dat;//由于4位的接线是接到P0口的高四位,所以传送高四位不用改
- delayms(5);
- EN=1; //写入时序
- delayms(5);
- EN=0;
- P0=dat<< 4; //写入低四位
- delayms(5);
- EN=1; //写入时序
- delayms(5);
- EN=0;
- }
- void initlcd()
- {
- lcdwc(0x32); //将8位总线转为4位总线
- lcdwc(0x28);//在四位线下的初始化
- delayms(5);
- lcdwc(0x0c);//00001100 显示开及光标设置
- lcdwc(0x06);//00000110 显示光标移动设置
- lcdwc(0x01);//00000001 清屏
-
- }
- void main()
- {
- uchar i;
- initlcd();
- lcdwc(0x80);//设置数据指针起点
- for(i=0;i<11;i++)
- {
- lcdwd(tab[i]);
- }
-
- System_Init();
- while(1)
- {
-
- }
- }
- void System_Init()
- {
- TMOD |= 0X10; //定时器1 16位计时模式
-
- TH1=(65536-1000)/256; //定时1ms中断一次 生成100HZ 的PWM信号
- TL1=(65536-1000)%256;
- TR1=1;
- ET1=1;
-
- IT0=1;//下降沿触发
- EX0=1;//打开中断0允许
- EA=1; //打开总中断
- IRIN=1;//初始化端口
- }
- /*******************************************************************************
- * 函数名 : DelayMs()
- * 函数功能 : 延时
- * 输入 : x
- * 输出 : 无
- *******************************************************************************/
- void Delay_Ms(unsigned int x) //0.14ms误差 0us
- {
- unsigned char i;
- while(x--)
- {
- for (i = 0; i<13; i++)
- {}
- }
- }

芯片解密