Files
C51-PWM/Listings/main.lst
2025-12-27 19:04:08 +08:00

116 lines
3.7 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

C51 COMPILER V9.60.0.0 MAIN 12/27/2025 19:02:38 PAGE 1
C51 COMPILER V9.60.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Objects\main.obj
COMPILER INVOKED BY: D:\keli\uv5_arm\C51\BIN\C51.EXE main.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.\Listings
-\main.lst) TABS(2) OBJECT(.\Objects\main.obj)
line level source
1 #include "REG51.h"
2 #include "INTRINS.h"
3
4 sbit K1 =P1^4 ; //增加键
5 sbit K2 =P1^5 ; //减少键
6 sbit P00 =P0^1;
7 unsigned char PWM=0xe7; //赋初值
8
9
10 void delayms(unsigned char ms);
11 void delay(unsigned char t);
12
13 /*********************************************************/
14 void main()
15 {
16 1
17 1 P1=0xff;
18 1 TMOD=0x21 ;
19 1 TH0=0xff ; //50us延时常数
20 1 TL0=0xce ; //频率调节
21 1
22 1 TH1=PWM ; //脉宽调节
23 1 TL1=0 ;
24 1
25 1 EA=1;
26 1 ET0=1;
27 1 ET1=1;
28 1
29 1 TR0=1 ;
30 1
31 1 while(1)
32 1 {
33 2 do{
34 3 if(PWM!=0xff)
35 3 {PWM++ ;delayms(10);}
36 3 else Beep() ;
*** WARNING C206 IN LINE 36 OF main.c: 'Beep': missing function-prototype
37 3 }
38 2 while(K1==0);
39 2
40 2 do{
41 3 if(PWM!=0xce)
42 3 {PWM-- ;delayms(10);}
43 3 else Beep() ;
44 3 }
45 2 while(K2==0);
46 2 }
47 1 }
48
49 void timer0() interrupt 1
50 {
51 1 TR1=0 ;
52 1 TH0=0xff ;
53 1 TL0=0xce ;
C51 COMPILER V9.60.0.0 MAIN 12/27/2025 19:02:38 PAGE 2
54 1 TH1=PWM ;
55 1 TR1=1 ;
56 1 P00=0 ; //启动输出
57 1 }
58
59
60 void timer1() interrupt 3
61 {
62 1 TR1=0 ;
63 1 P00=1 ; //结束输出
64 1 }
65
66
67 /*********************************************************/
68 // 延时子程序
69 /*********************************************************/
70 void delay(unsigned char t)
71 {
72 1 while(t--) ;
73 1 }
74
75 /*********************************************************/
76 // 延时子程序
77 /*********************************************************/
78 void delayms(unsigned char ms)
79
80 {
81 1 unsigned char i ;
82 1 while(ms--)
83 1 {
84 2 for(i = 0 ; i < 120 ; i++) ;
85 2 }
86 1 }
87
88 /*********************************************************/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 119 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)