C51 COMPILER V9.56.0.0 PWM 04/06/2022 21:56:10 PAGE 1 C51 COMPILER V9.56.0.0, COMPILATION OF MODULE PWM OBJECT MODULE PLACED IN pwm.OBJ COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE pwm.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND TABS(2) line level source 1 #include "pwm.h" 2 3 unsigned char pwm_val_left =0;//变量定义 4 unsigned char push_val_left =0;// 左电机占空比N/20 5 unsigned char pwm_val_right =0; 6 unsigned char push_val_right=0;// 右电机占空比N/20 7 unsigned char pwm_left=0; 8 9 bit Right_moto_stop=1; 10 bit Left_moto_stop =1; 11 12 unsigned int time1=0; 13 14 15 16 /************************************************************************/ 17 //延时函数 18 void delay(unsigned int k) 19 { 20 1 unsigned int x,y; 21 1 for(x=0;x=20) 74 2 pwm_val_left=0; 75 2 } 76 1 else 77 1 { 78 2 Left_moto_pwm=0; 79 2 } 80 1 } 81 /******************************************************************/ 82 /* 右电机调速 */ 83 void pwm_out_right_moto(void) 84 { 85 1 if(Right_moto_stop) 86 1 { 87 2 if(pwm_val_right<=push_val_right) 88 2 { 89 3 Right_moto_pwm=1; 90 3 } 91 2 else 92 2 { 93 3 Right_moto_pwm=0; 94 3 } 95 2 if(pwm_val_right>=20) 96 2 pwm_val_right=0; 97 2 } 98 1 else 99 1 { 100 2 Right_moto_pwm=0; 101 2 } 102 1 } 103 104 void timer1()interrupt 3 105 { 106 1 TH1=0XFc; //1Ms定时 107 1 TL1=0X18; 108 1 time1++; 109 1 // pwm_val_left++; 110 1 pwm_val_right++; 111 1 // pwm_out_left_moto(); 112 1 pwm_out_right_moto(); 113 1 } 114 115 116 117 C51 COMPILER V9.56.0.0 PWM 04/06/2022 21:56:10 PAGE 3 MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 172 ---- CONSTANT SIZE = ---- ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = 7 ---- IDATA SIZE = ---- ---- BIT SIZE = 2 ---- END OF MODULE INFORMATION. C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)