C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 1 C51 COMPILER V9.59.0.0, COMPILATION OF MODULE PWM15BIT OBJECT MODULE PLACED IN .\list\PWM15bit.obj COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE PWM15bit.c LARGE OMF2 OPTIMIZE(8,SPEED) BROWSE DEBUG PRINT(.\list\PWM15b -it.lst) TABS(2) OBJECT(.\list\PWM15bit.obj) line level source 1 /*---------------------------------------------------------------------*/ 2 /* --- STC MCU Limited ------------------------------------------------*/ 3 /* --- STC 1T Series MCU Demo Programme -------------------------------*/ 4 /* --- Mobile: (86)13922805190 ----------------------------------------*/ 5 /* --- Fax: 86-0513-55012956,55012947,55012969 ------------------------*/ 6 /* --- Tel: 86-0513-55012928,55012929,55012966 ------------------------*/ 7 /* --- Web: www.STCMCU.com --------------------------------------------*/ 8 /* --- Web: www.STCMCUDATA.com ---------------------------------------*/ 9 /* --- QQ: 800003751 -------------------------------------------------*/ 10 /* Èç¹ûÒªÔÚ³ÌÐòÖÐʹÓô˴úÂë,ÇëÔÚ³ÌÐòÖÐ×¢Ã÷ʹÓÃÁËSTCµÄ×ÊÁϼ°³ÌÐò */ 11 /*---------------------------------------------------------------------*/ 12 13 #include "PWM15bit.h" 14 15 u16 code PWMxCR[48] = { 16 0xff14, /* PWM00CR */ 17 0xff1c, /* PWM01CR */ 18 0xff24, /* PWM02CR */ 19 0xff2c, /* PWM03CR */ 20 0xff34, /* PWM04CR */ 21 0xff3c, /* PWM05CR */ 22 0xff44, /* PWM06CR */ 23 0xff4c, /* PWM07CR */ 24 0xff64, /* PWM10CR */ 25 0xff6c, /* PWM11CR */ 26 0xff74, /* PWM12CR */ 27 0xff7c, /* PWM13CR */ 28 0xff84, /* PWM14CR */ 29 0xff8c, /* PWM15CR */ 30 0xff94, /* PWM16CR */ 31 0xff9c, /* PWM17CR */ 32 0xffb4, /* PWM20CR */ 33 0xffbc, /* PWM21CR */ 34 0xffc4, /* PWM22CR */ 35 0xffcc, /* PWM23CR */ 36 0xffd4, /* PWM24CR */ 37 0xffdc, /* PWM25CR */ 38 0xffe4, /* PWM26CR */ 39 0xffec, /* PWM27CR */ 40 0xfc14, /* PWM30CR */ 41 0xfc1c, /* PWM31CR */ 42 0xfc24, /* PWM32CR */ 43 0xfc2c, /* PWM33CR */ 44 0xfc34, /* PWM34CR */ 45 0xfc3c, /* PWM35CR */ 46 0xfc44, /* PWM36CR */ 47 0xfc4c, /* PWM37CR */ 48 0xfc64, /* PWM40CR */ 49 0xfc6c, /* PWM41CR */ 50 0xfc74, /* PWM42CR */ 51 0xfc7c, /* PWM43CR */ 52 0xfc84, /* PWM44CR */ 53 0xfc8c, /* PWM45CR */ 54 0xfc94, /* PWM46CR */ C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 2 55 0xfc9c, /* PWM47CR */ 56 0xfcb4, /* PWM50CR */ 57 0xfcbc, /* PWM51CR */ 58 0xfcc4, /* PWM52CR */ 59 0xfccc, /* PWM53CR */ 60 0xfcd4, /* PWM54CR */ 61 0xfcdc, /* PWM55CR */ 62 0xfce4, /* PWM56CR */ 63 0xfcec, /* PWM57CR */ 64 }; 65 66 u16 code PWMxT1[48] = { 67 0xff10, /* PWM00T1 */ 68 0xff18, /* PWM01T1 */ 69 0xff20, /* PWM02T1 */ 70 0xff28, /* PWM03T1 */ 71 0xff30, /* PWM04T1 */ 72 0xff38, /* PWM05T1 */ 73 0xff40, /* PWM06T1 */ 74 0xff48, /* PWM07T1 */ 75 0xff60, /* PWM10T1 */ 76 0xff68, /* PWM11T1 */ 77 0xff70, /* PWM12T1 */ 78 0xff78, /* PWM13T1 */ 79 0xff80, /* PWM14T1 */ 80 0xff88, /* PWM15T1 */ 81 0xff90, /* PWM16T1 */ 82 0xff98, /* PWM17T1 */ 83 0xffb0, /* PWM20T1 */ 84 0xffb8, /* PWM21T1 */ 85 0xffc0, /* PWM22T1 */ 86 0xffc8, /* PWM23T1 */ 87 0xffd0, /* PWM24T1 */ 88 0xffd8, /* PWM25T1 */ 89 0xffe0, /* PWM26T1 */ 90 0xffe8, /* PWM27T1 */ 91 0xfc10, /* PWM30T1 */ 92 0xfc18, /* PWM31T1 */ 93 0xfc20, /* PWM32T1 */ 94 0xfc28, /* PWM33T1 */ 95 0xfc30, /* PWM34T1 */ 96 0xfc38, /* PWM35T1 */ 97 0xfc40, /* PWM36T1 */ 98 0xfc48, /* PWM37T1 */ 99 0xfc60, /* PWM40T1 */ 100 0xfc68, /* PWM41T1 */ 101 0xfc70, /* PWM42T1 */ 102 0xfc78, /* PWM43T1 */ 103 0xfc80, /* PWM44T1 */ 104 0xfc88, /* PWM45T1 */ 105 0xfc90, /* PWM46T1 */ 106 0xfc98, /* PWM47T1 */ 107 0xfcb0, /* PWM50T1 */ 108 0xfcb8, /* PWM51T1 */ 109 0xfcc0, /* PWM52T1 */ 110 0xfcc8, /* PWM53T1 */ 111 0xfcd0, /* PWM54T1 */ 112 0xfcd8, /* PWM55T1 */ 113 0xfce0, /* PWM56T1 */ 114 0xfce8, /* PWM57T1 */ 115 }; 116 C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 3 117 u16 code PWMxT2[48] = { 118 0xff12, /* PWM00T2 */ 119 0xff1a, /* PWM01T2 */ 120 0xff22, /* PWM02T2 */ 121 0xff2a, /* PWM03T2 */ 122 0xff32, /* PWM04T2 */ 123 0xff3a, /* PWM05T2 */ 124 0xff42, /* PWM06T2 */ 125 0xff4a, /* PWM07T2 */ 126 0xff62, /* PWM10T2 */ 127 0xff6a, /* PWM11T2 */ 128 0xff72, /* PWM12T2 */ 129 0xff7a, /* PWM13T2 */ 130 0xff82, /* PWM14T2 */ 131 0xff8a, /* PWM15T2 */ 132 0xff92, /* PWM16T2 */ 133 0xff9a, /* PWM17T2 */ 134 0xffb2, /* PWM20T2 */ 135 0xffba, /* PWM21T2 */ 136 0xffc2, /* PWM22T2 */ 137 0xffca, /* PWM23T2 */ 138 0xffd2, /* PWM24T2 */ 139 0xffda, /* PWM25T2 */ 140 0xffe2, /* PWM26T2 */ 141 0xffea, /* PWM27T2 */ 142 0xfc12, /* PWM30T2 */ 143 0xfc1a, /* PWM31T2 */ 144 0xfc22, /* PWM32T2 */ 145 0xfc2a, /* PWM33T2 */ 146 0xfc32, /* PWM34T2 */ 147 0xfc3a, /* PWM35T2 */ 148 0xfc42, /* PWM36T2 */ 149 0xfc4a, /* PWM37T2 */ 150 0xfc62, /* PWM40T2 */ 151 0xfc6a, /* PWM41T2 */ 152 0xfc72, /* PWM42T2 */ 153 0xfc7a, /* PWM43T2 */ 154 0xfc82, /* PWM44T2 */ 155 0xfc8a, /* PWM45T2 */ 156 0xfc92, /* PWM46T2 */ 157 0xfc9a, /* PWM47T2 */ 158 0xfcb2, /* PWM50T2 */ 159 0xfcba, /* PWM51T2 */ 160 0xfcc2, /* PWM52T2 */ 161 0xfcca, /* PWM53T2 */ 162 0xfcd2, /* PWM54T2 */ 163 0xfcda, /* PWM55T2 */ 164 0xfce2, /* PWM56T2 */ 165 0xfcea, /* PWM57T2 */ 166 }; 167 168 u16 code PWMxHLD[48] = { 169 0xff15, /* PWM00HLD */ 170 0xff1d, /* PWM01HLD */ 171 0xff25, /* PWM02HLD */ 172 0xff2d, /* PWM03HLD */ 173 0xff35, /* PWM04HLD */ 174 0xff3d, /* PWM05HLD */ 175 0xff45, /* PWM06HLD */ 176 0xff4d, /* PWM07HLD */ 177 0xff65, /* PWM10HLD */ 178 0xff6d, /* PWM11HLD */ C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 4 179 0xff75, /* PWM12HLD */ 180 0xff7d, /* PWM13HLD */ 181 0xff85, /* PWM14HLD */ 182 0xff8d, /* PWM15HLD */ 183 0xff95, /* PWM16HLD */ 184 0xff9d, /* PWM17HLD */ 185 0xffb5, /* PWM20HLD */ 186 0xffbd, /* PWM21HLD */ 187 0xffc5, /* PWM22HLD */ 188 0xffcd, /* PWM23HLD */ 189 0xffd5, /* PWM24HLD */ 190 0xffdd, /* PWM25HLD */ 191 0xffe5, /* PWM26HLD */ 192 0xffed, /* PWM27HLD */ 193 0xfc15, /* PWM30HLD */ 194 0xfc1d, /* PWM31HLD */ 195 0xfc25, /* PWM32HLD */ 196 0xfc2d, /* PWM33HLD */ 197 0xfc35, /* PWM34HLD */ 198 0xfc3d, /* PWM35HLD */ 199 0xfc45, /* PWM36HLD */ 200 0xfc4d, /* PWM37HLD */ 201 0xfc65, /* PWM40HLD */ 202 0xfc6d, /* PWM41HLD */ 203 0xfc75, /* PWM42HLD */ 204 0xfc7d, /* PWM43HLD */ 205 0xfc85, /* PWM44HLD */ 206 0xfc8d, /* PWM45HLD */ 207 0xfc95, /* PWM46HLD */ 208 0xfc9d, /* PWM47HLD */ 209 0xfcb5, /* PWM50HLD */ 210 0xfcbd, /* PWM51HLD */ 211 0xfcc5, /* PWM52HLD */ 212 0xfccd, /* PWM53HLD */ 213 0xfcd5, /* PWM54HLD */ 214 0xfcdd, /* PWM55HLD */ 215 0xfce5, /* PWM56HLD */ 216 0xfced, /* PWM57HLD */ 217 }; 218 219 //======================================================================== 220 // º¯Êý: u8 PWMChannelCtrl(u8 PWM_id, u8 pwm_eno, u8 pwm_ini, u8 pwm_eni, u8 pwm_ent2i, u8 pwm_ent1i) 221 // ÃèÊö: PWMͨµÀ¿ØÖƼĴæÆ÷ÉèÖÃ. 222 // ²ÎÊý: PWM_id: PWMͨµÀÐòºÅ. È¡Öµ 0~57 223 // pwm_eno: pwmÊä³öʹÄÜ, 0ÉèΪGPIO, 1ÉèΪPWMÊä³ö. 224 // pwm_ini: pwmÊä³ö¶ËµÄ³õʼµçƽ, 0ΪµÍµçƽ, 1Ϊ¸ßµçƽ. 225 // pwm_eni: pwmͨµÀÖжÏʹÄÜ¿ØÖÆ, 0Ϊ¹Ø±ÕPWMÖжÏ, 1ΪʹÄÜPWMÖжÏ. 226 // pwm_ent2i: pwmͨµÀµÚ¶þ¸ö´¥·¢µãÖжÏʹÄÜ¿ØÖÆ, 0Ϊ¹Ø±ÕPWMµÚ¶þ¸ö´¥·¢µãÖжÏ, 1ΪʹÄÜPWMµÚ¶þ¸ö´¥·¢µãÖжÏ. 227 // pwm_ent1i: pwmͨµÀµÚÒ»¸ö´¥·¢µãÖжÏʹÄÜ¿ØÖÆ, 0Ϊ¹Ø±ÕPWMµÚÒ»¸ö´¥·¢µãÖжÏ, 1ΪʹÄÜPWMµÚÒ»¸ö´¥·¢µãÖжÏ. 228 // ·µ»Ø: 0:ÕýÈ·, 2:´íÎó. 229 // °æ±¾: V1.0, 2020-09-22 230 //======================================================================== 231 u8 PWMChannelCtrl(u8 PWM_id, u8 pwm_eno, u8 pwm_ini, u8 pwm_eni, u8 pwm_ent2i, u8 pwm_ent1i) 232 { 233 1 u8 xdata *pPWMxCR; 234 1 235 1 if(PWM_id > PWM57) return 2; //id´íÎó 236 1 if(pwm_eno > 1) return 2; //Êä³öʹÄÜ´íÎó 237 1 if(pwm_ini > 1) return 2; //Êä³ö¶ËµÄ³õʼµçƽ´íÎó 238 1 if(pwm_eni > 1) return 2; //ÖжÏʹÄÜ¿ØÖÆ´íÎó 239 1 if(pwm_ent2i > 1) return 2; //µÚ¶þ¸ö´¥·¢µãÖжÏʹÄÜ¿ØÖÆ´íÎó 240 1 if(pwm_ent1i > 1) return 2; //µÚÒ»¸ö´¥·¢µãÖжÏʹÄÜ¿ØÖÆ´íÎó C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 5 241 1 242 1 EAXSFR(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹SFR(XSFR) */ 243 1 pPWMxCR = (u8 *)PWMxCR[PWM_id]; 244 1 *pPWMxCR = (pwm_eno << 7) | (pwm_ini << 6) | (pwm_eni << 2)| (pwm_ent2i << 1)| pwm_ent1i; 245 1 EAXRAM(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹RAM(XRAM) */ 246 1 return 0; 247 1 } 248 249 //======================================================================== 250 // º¯Êý: u8 PWMPeriodDuty(u8 PWM_id, u16 Period, u16 dutyL, u16 dutyH) 251 // ÃèÊö: PWMÖÜÆÚ, Õ¼¿Õ±ÈÉèÖÃ. 252 // ²ÎÊý: PWM_id: PWMͨµÀÐòºÅ. È¡Öµ 0~57 253 // dutyL: pwmÊä³öµÍµçƽλÖÃ, È¡Öµ 0~0x7fff. 254 // dutyH: pwmÊä³ö¸ßµçƽλÖÃ, È¡Öµ 0~0x7fff. 255 // ·µ»Ø: 0:ÕýÈ·, 2:´íÎó. 256 // °æ±¾: V1.0, 2020-09-22 257 //======================================================================== 258 u8 PWM15Duty(u8 PWM_id, u16 dutyL, u16 dutyH) 259 { 260 1 u16 xdata *pPWMxT1; 261 1 u16 xdata *pPWMxT2; 262 1 263 1 if(PWM_id > PWM57) return 2; //id´íÎó 264 1 if(dutyL > 0x7fff) return 2; //µÍµçƽʱ¼äÉèÖôíÎó 265 1 if(dutyH > 0x7fff) return 2; //¸ßµçƽʱ¼äÉèÖôíÎó 266 1 267 1 EAXSFR(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹SFR(XSFR) */ 268 1 pPWMxT1 = (u16 *)PWMxT1[PWM_id]; 269 1 *pPWMxT1 = dutyL & 0x7fff; 270 1 271 1 pPWMxT2 = (u16 *)PWMxT2[PWM_id]; 272 1 *pPWMxT2 = dutyH & 0x7fff; 273 1 EAXRAM(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹RAM(XRAM) */ 274 1 return 0; 275 1 } 276 277 //======================================================================== 278 // º¯Êý: u8 PWMOutputSet(u8 PWM_id, u8 pwm_hldl, u8 pwm_hldh) 279 // ÃèÊö: PWMͨµÀ¿ØÖƼĴæÆ÷ÉèÖÃ. 280 // ²ÎÊý: PWM_id: PWMͨµÀÐòºÅ. È¡Öµ 0~57 281 // pwm_hldl: pwmÇ¿ÖÆÊä³öµÍµçƽ¿ØÖÆλ, 0Õý³£Êä³ö, 1Ç¿ÖÆÊä³öµÍµçƽ. 282 // pwm_hldh: pwmÇ¿ÖÆÊä³ö¸ßµçƽ¿ØÖÆλ, 0Õý³£Êä³ö, 1Ç¿ÖÆÊä³ö¸ßµçƽ. 283 // ·µ»Ø: 0:ÕýÈ·, 2:´íÎó. 284 // °æ±¾: V1.0, 2020-09-22 285 //======================================================================== 286 u8 PWMLevelSet(u8 PWM_id, u8 pwm_hldl, u8 pwm_hldh) 287 { 288 1 u8 xdata *pPWMxHLD; 289 1 290 1 if(PWM_id > PWM57) return 2; //id´íÎó 291 1 if(pwm_hldh > 1) return 2; //Êä³öʹÄÜ´íÎó 292 1 if(pwm_hldl > 1) return 2; //Êä³ö¶ËµÄ³õʼµçƽ´íÎó 293 1 294 1 EAXSFR(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹SFR(XSFR) */ 295 1 pPWMxHLD = (u8 *)PWMxHLD[PWM_id]; 296 1 *pPWMxHLD = (pwm_hldh << 1) | pwm_hldl; 297 1 EAXRAM(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹RAM(XRAM) */ 298 1 return 0; 299 1 } 300 301 //======================================================================== 302 // º¯Êý: void PWM15_Init(u8 PWM_id, PWM15_InitTypeDef *PWMx) C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 6 303 // ÃèÊö: 15λÔöÇ¿ÐÍPWM³õʼ»¯³ÌÐò. 304 // ²ÎÊý: PWM_id: PWM×éºÅ. È¡Öµ PWM0,PWM1,PWM2,PWM3,PWM4,PWM5 305 // PWMx: ½á¹¹²ÎÊý,Çë²Î¿¼Í·ÎļþÀïµÄ¶¨Òå. 306 // ·µ»Ø: none. 307 // °æ±¾: V1.0, 2020-09-22 308 //======================================================================== 309 void PWM15_Init(u8 PWM_id, PWM15_InitTypeDef *PWMx) 310 { 311 1 if(PWM_id > PWM5) return; //id´íÎó 312 1 313 1 EAXSFR(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹SFR(XSFR) */ 314 1 if(PWM_id == PWM0) 315 1 { 316 2 if(PWMx->PWM_Enable == ENABLE) PWM15_PWM0_Enable(); //ʹÄÜPWM0 317 2 else PWM15_PWM0_Disable(); //¹Ø±ÕPWM0 318 2 PWM0_PS_Set(PWMx->PWM_Clock_PS); //ϵͳʱÖÓ·ÖƵ²ÎÊý, 0~15 319 2 PWM0C = PWMx->PWM_Period & 0x7fff; 320 2 if(PWMx->PWM_Counter == ENABLE) PWM15_Counter0_Enable(); //ʹÄܼÆÊýÆ÷ 321 2 else PWM15_Counter0_Disable(); //¹Ø±Õ¼ÆÊýÆ÷ 322 2 } 323 1 324 1 if(PWM_id == PWM1) 325 1 { 326 2 if(PWMx->PWM_Enable == ENABLE) PWM15_PWM1_Enable(); //ʹÄÜPWM1 327 2 else PWM15_PWM1_Disable(); //¹Ø±ÕPWM1 328 2 PWM1_PS_Set(PWMx->PWM_Clock_PS); //ϵͳʱÖÓ·ÖƵ²ÎÊý, 0~15 329 2 PWM1C = PWMx->PWM_Period & 0x7fff; 330 2 if(PWMx->PWM_Counter == ENABLE) PWM15_Counter1_Enable(); //ʹÄܼÆÊýÆ÷ 331 2 else PWM15_Counter1_Disable(); //¹Ø±Õ¼ÆÊýÆ÷ 332 2 } 333 1 334 1 if(PWM_id == PWM2) 335 1 { 336 2 if(PWMx->PWM_Enable == ENABLE) PWM15_PWM2_Enable(); //ʹÄÜPWM2 337 2 else PWM15_PWM2_Disable(); //¹Ø±ÕPWM2 338 2 PWM2_PS_Set(PWMx->PWM_Clock_PS); //ϵͳʱÖÓ·ÖƵ²ÎÊý, 0~15 339 2 PWM2C = PWMx->PWM_Period & 0x7fff; 340 2 if(PWMx->PWM_Counter == ENABLE) PWM15_Counter2_Enable(); //ʹÄܼÆÊýÆ÷ 341 2 else PWM15_Counter2_Disable(); //¹Ø±Õ¼ÆÊýÆ÷ 342 2 } 343 1 344 1 if(PWM_id == PWM3) 345 1 { 346 2 if(PWMx->PWM_Enable == ENABLE) PWM15_PWM3_Enable(); //ʹÄÜPWM3 347 2 else PWM15_PWM3_Disable(); //¹Ø±ÕPWM3 348 2 PWM3_PS_Set(PWMx->PWM_Clock_PS); //ϵͳʱÖÓ·ÖƵ²ÎÊý, 0~15 349 2 PWM3C = PWMx->PWM_Period & 0x7fff; 350 2 if(PWMx->PWM_Counter == ENABLE) PWM15_Counter3_Enable(); //ʹÄܼÆÊýÆ÷ 351 2 else PWM15_Counter3_Disable(); //¹Ø±Õ¼ÆÊýÆ÷ 352 2 } 353 1 354 1 if(PWM_id == PWM4) 355 1 { 356 2 if(PWMx->PWM_Enable == ENABLE) PWM15_PWM4_Enable(); //ʹÄÜPWM4 357 2 else PWM15_PWM4_Disable(); //¹Ø±ÕPWM4 358 2 PWM4_PS_Set(PWMx->PWM_Clock_PS); //ϵͳʱÖÓ·ÖƵ²ÎÊý, 0~15 359 2 PWM4C = PWMx->PWM_Period & 0x7fff; 360 2 if(PWMx->PWM_Counter == ENABLE) PWM15_Counter4_Enable(); //ʹÄܼÆÊýÆ÷ 361 2 else PWM15_Counter4_Disable(); //¹Ø±Õ¼ÆÊýÆ÷ 362 2 } 363 1 364 1 if(PWM_id == PWM5) C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 7 365 1 { 366 2 if(PWMx->PWM_Enable == ENABLE) PWM15_PWM5_Enable(); //ʹÄÜPWM5 367 2 else PWM15_PWM5_Disable(); //¹Ø±ÕPWM5 368 2 PWM5_PS_Set(PWMx->PWM_Clock_PS); //ϵͳʱÖÓ·ÖƵ²ÎÊý, 0~15 369 2 PWM5C = PWMx->PWM_Period & 0x7fff; 370 2 if(PWMx->PWM_Counter == ENABLE) PWM15_Counter5_Enable(); //ʹÄܼÆÊýÆ÷ 371 2 else PWM15_Counter5_Disable(); //¹Ø±Õ¼ÆÊýÆ÷ 372 2 } 373 1 EAXRAM(); /* MOVX A,@DPTR/MOVX @DPTR,AÖ¸ÁîµÄ²Ù×÷¶ÔÏóΪÀ©Õ¹RAM(XRAM) */ 374 1 } 375 376 377 //======================================================================== 378 // º¯Êý: void PWM0_Handler (void) interrupt PWM0_VECTOR 379 // ÃèÊö: PWM0Öжϴ¦Àí³ÌÐò. 380 // ²ÎÊý: None 381 // ·µ»Ø: none. 382 // °æ±¾: V1.0, 2020-10-13 383 //======================================================================== 384 void PWM0_Handler (void) interrupt PWM0_VECTOR 385 { 386 1 char store; 387 1 store = P_SW2; 388 1 P_SW2 |= 0x80; 389 1 390 1 if(PWMCFG01 & 0x08) //PWM0ÖÐ¶Ï 391 1 { 392 2 PWMCFG01 &= ~0x08; //ÇåPWM0ÖжϱêÖ¾ 393 2 // TODO: ÔÚ´Ë´¦Ìí¼ÓÓû§´úÂë 394 2 } 395 1 if(PWM0IF) 396 1 { 397 2 PWM0IF = 0; 398 2 P27 = ~P27; 399 2 } 400 1 P_SW2 = store; 401 1 } 402 //======================================================================== 403 // º¯Êý: void PWM1_Handler (void) interrupt PWM1_VECTOR 404 // ÃèÊö: PWM1Öжϴ¦Àí³ÌÐò. 405 // ²ÎÊý: None 406 // ·µ»Ø: none. 407 // °æ±¾: V1.0, 2020-10-13 408 //======================================================================== 409 void PWM1_Handler (void) interrupt PWM1_VECTOR 410 { 411 1 char store; 412 1 store = P_SW2; 413 1 P_SW2 |= 0x80; 414 1 415 1 if(PWMCFG01 & 0x80) //PWM1ÖÐ¶Ï 416 1 { 417 2 PWMCFG01 &= ~0x80; //ÇåPWM1ÖжϱêÖ¾ 418 2 // TODO: ÔÚ´Ë´¦Ìí¼ÓÓû§´úÂë 419 2 } 420 1 if(PWM1IF) 421 1 { 422 2 PWM1IF = 0; 423 2 P26 = ~P26; 424 2 } 425 1 P_SW2 = store; 426 1 } C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 8 427 //======================================================================== 428 // º¯Êý: void PWM2_Handler (void) interrupt PWM2_VECTOR 429 // ÃèÊö: PWM2Öжϴ¦Àí³ÌÐò. 430 // ²ÎÊý: None 431 // ·µ»Ø: none. 432 // °æ±¾: V1.0, 2020-10-13 433 //======================================================================== 434 void PWM2_Handler (void) interrupt PWM2_VECTOR 435 { 436 1 char store; 437 1 store = P_SW2; 438 1 P_SW2 |= 0x80; 439 1 440 1 if(PWMCFG23 & 0x08) //PWM2ÖÐ¶Ï 441 1 { 442 2 PWMCFG23 &= ~0x08; //ÇåPWM2ÖжϱêÖ¾ 443 2 // TODO: ÔÚ´Ë´¦Ìí¼ÓÓû§´úÂë 444 2 } 445 1 if(PWM2IF) 446 1 { 447 2 PWM2IF = 0; 448 2 P25 = ~P25; 449 2 } 450 1 P_SW2 = store; 451 1 } 452 //======================================================================== 453 // º¯Êý: void PWM3_Handler (void) interrupt PWM3_VECTOR 454 // ÃèÊö: PWM3Öжϴ¦Àí³ÌÐò. 455 // ²ÎÊý: None 456 // ·µ»Ø: none. 457 // °æ±¾: V1.0, 2020-10-13 458 //======================================================================== 459 void PWM3_Handler (void) interrupt PWM3_VECTOR 460 { 461 1 char store; 462 1 store = P_SW2; 463 1 P_SW2 |= 0x80; 464 1 465 1 if(PWMCFG23 & 0x80) //PWM3ÖÐ¶Ï 466 1 { 467 2 PWMCFG23 &= ~0x80; //ÇåPWM3ÖжϱêÖ¾ 468 2 // TODO: ÔÚ´Ë´¦Ìí¼ÓÓû§´úÂë 469 2 } 470 1 if(PWM3IF) 471 1 { 472 2 PWM3IF = 0; 473 2 P24 = ~P24; 474 2 } 475 1 P_SW2 = store; 476 1 } 477 //======================================================================== 478 // º¯Êý: void PWM4_Handler (void) interrupt PWM4_VECTOR 479 // ÃèÊö: PWM4Öжϴ¦Àí³ÌÐò. 480 // ²ÎÊý: None 481 // ·µ»Ø: none. 482 // °æ±¾: V1.0, 2020-10-13 483 //======================================================================== 484 void PWM4_Handler (void) interrupt PWM4_VECTOR 485 { 486 1 char store; 487 1 store = P_SW2; 488 1 P_SW2 |= 0x80; C51 COMPILER V9.59.0.0 PWM15BIT 03/09/2021 14:07:43 PAGE 9 489 1 490 1 if(PWMCFG45 & 0x08) //PWM4ÖÐ¶Ï 491 1 { 492 2 PWMCFG45 &= ~0x08; //ÇåPWM4ÖжϱêÖ¾ 493 2 // TODO: ÔÚ´Ë´¦Ìí¼ÓÓû§´úÂë 494 2 } 495 1 if(PWM4IF) 496 1 { 497 2 PWM4IF = 0; 498 2 P23 = ~P23; 499 2 } 500 1 P_SW2 = store; 501 1 } 502 //======================================================================== 503 // º¯Êý: void PWM5_Handler (void) interrupt PWM5_VECTOR 504 // ÃèÊö: PWM5Öжϴ¦Àí³ÌÐò. 505 // ²ÎÊý: None 506 // ·µ»Ø: none. 507 // °æ±¾: V1.0, 2020-10-13 508 //======================================================================== 509 //void PWM5_Handler (void) interrupt PWM5_VECTOR //ÖжÏÏòÁ¿ºÅ³¬¹ý31£¬¿É½èÖúÆäËüÖжϺÅÌøת£¬·½·¨Ïê¼û¹æ¸ñÊé½ -éÉÜ 510 //{ 511 // if(PWMCFG45 & 0x80) //PWM5ÖÐ¶Ï 512 // { 513 // PWMCFG45 &= ~0x80; //ÇåPWM5ÖжϱêÖ¾ 514 // // TODO: ÔÚ´Ë´¦Ìí¼ÓÓû§´úÂë 515 // } 516 //} MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 1084 ---- CONSTANT SIZE = 384 ---- XDATA SIZE = ---- 8 PDATA SIZE = ---- ---- DATA SIZE = ---- ---- IDATA SIZE = ---- ---- BIT SIZE = ---- ---- EDATA SIZE = ---- ---- HDATA SIZE = ---- ---- XDATA CONST SIZE = ---- ---- FAR CONST SIZE = ---- ---- END OF MODULE INFORMATION. C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)