c8051f410单片机步进电机控制系统单片机解密
- 单片机解密void PCA_Init()
- {
- PCA0MD &= ~0x40;
- PCA0MD = 0x00;
- }
- void Timer_Init()
- {
- TCON = 0x10;
- TMOD = 0x02;
- TL0 = 0x38;
- TH0 = 0x38;
- }
- void Port_IO_Init()
- {
- P0MDOUT = 0xFF;
- XBR1 = 0x40;
- }
- void Oscillator_Init()
- {
- OSCICN = 0x87;
- }
- void Interrupts_Init()
- {
- IE = 0x82;
- }
- // Initialization function for device,
- // Call Init_Device() from your main program
- void Init_Device(void)
- {
- PCA_Init();
- Timer_Init();
- Port_IO_Init();
- Oscillator_Init();
- Interrupts_Init();
- }
- //单四拍驱动正转(N*360/200)度
- void m_single_pos(unsigned int N)
- {
- beat=4; //拍数
- p1=single_pos;
- p2=single_pos+beat;
- step=N;
- TR0=1;//开定时器0,电机运行
- while(1)
- {
- P0=*p1;
- if(step==0)
- {
- P0=0x00;
- TR0=0;//关定时器0
- break;
- }
- }
- }
- //单四拍驱动反转(N*360/200)度
- void m_single_rev(unsigned int N)
- {
- beat=4;
- p1=single_rev;
- p2=single_rev+beat;
- step=N;
- TR0=1;// 开定时器0,电机运行
- while(1)
- {
- P0=*p1;
-
- if(step==0)
- {
- P0=0x00;
- TR0=0;//关定时器0
- break;
- }
- }
- }
- //双四拍驱动正转(N*360/200)度
- void m_double_pos(unsigned int N)
- {
- beat=4;
- p1=double_pos;
- p2=double_pos+beat;
- step=N;
- TR0=1;// 开定时器0,电机运行
- while(1)
- {
- P0=*p1;
-
- if(step==0)
- {
- P0=0x00;
- TR0=0;//关定时器0
- break;
- }
- }
- }

芯片解密