From 314868325d7d7463234470d0079c2aadee490b93 Mon Sep 17 00:00:00 2001 From: cyp0633 Date: Tue, 23 Aug 2022 16:14:12 +0800 Subject: [PATCH] Problem 10 --- 10/10.uvopt | 197 +++++++++++++++++++++++++ 10/10.uvproj | 395 +++++++++++++++++++++++++++++++++++++++++++++++++++ 10/main.c | 55 +++++++ 3 files changed, 647 insertions(+) create mode 100644 10/10.uvopt create mode 100644 10/10.uvproj create mode 100644 10/main.c diff --git a/10/10.uvopt b/10/10.uvopt new file mode 100644 index 0000000..a99d45e --- /dev/null +++ b/10/10.uvopt @@ -0,0 +1,197 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + Target 1 + 0x0 + MCS-51 + + 35000000 + + 1 + 1 + 1 + 0 + 0 + + + 0 + 65535 + 0 + 0 + 0 + + + 120 + 65 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + 1 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + -1 + + + + + + + + + + + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + Source Group 1 + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + .\main.c + main.c + 0 + 0 + + + 1 + 2 + 4 + 0 + 0 + 0 + .\STCBSP_V3.6.LIB + STCBSP_V3.6.LIB + 0 + 0 + + + +
diff --git a/10/10.uvproj b/10/10.uvproj new file mode 100644 index 0000000..449807c --- /dev/null +++ b/10/10.uvproj @@ -0,0 +1,395 @@ + + + + 1.1 + +
### uVision Project, (C) Keil Software
+ + + + Target 1 + 0x0 + MCS-51 + 0 + + + STC15F2K60S2 Series + STC + IRAM(0-0xFF) XRAM(0-0x6FF) IROM(0-0xEFF8) CLOCK(35000000) MODP2 + + "LIB\STARTUP.A51" ("Standard 8051 Startup Code") + + 62472 + STC15F2K60S2.H + + + + + + + + + + + 0 + 0 + + + + STC\ + STC\ + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + 10 + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 0 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + 65535 + + + S8051.DLL + + DP51.DLL + -pDP8051 + S8051.DLL + + TP51.DLL + -p51 + + + + 0 + 0 + 0 + 0 + 16 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + + + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + + 0 + -1 + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + 0 + 0 + -1 + + 0 + + + + + + + 0 + + + + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 0 + 0x0 + 0x10000 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0xeff9 + + + 0 + 0x0 + 0x100 + + + 0 + 0x0 + 0x700 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + + + 0 + 0 + 1 + 0 + 1 + 3 + 8 + 2 + 1 + 1 + 0 + 0 + + + + + ..\inc + + + + 0 + 1 + 0 + 0 + + + + + + + + + 0 + 0 + 1 + 0 + 2 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Source Group 1 + + + main.c + 1 + .\main.c + + + STCBSP_V3.6.LIB + 4 + .\STCBSP_V3.6.LIB + + + + + + + +
diff --git a/10/main.c b/10/main.c new file mode 100644 index 0000000..781ff23 --- /dev/null +++ b/10/main.c @@ -0,0 +1,55 @@ +// ultrasonic distance sensor +#include "EXT.h" +#include "STC15F2K60S2.H" +#include "displayer.h" +#include "key.h" +#include "sys.h" +#include "universal_decode_table.h" + +code unsigned long SysClock = 11059200; //必须。定义系统工作时钟频率(Hz),用户必须修改成与实际工作频率(下载时选择的)一致 +char status = 0; + +void spin1() // 50% +{ + SetPWM(0, 0, 50, 500); + LedPrint(8); +} + +void spin2() // 30% reverse +{ + SetPWM(50, 300, 0, 0); + LedPrint(16); +} + +void select() +{ + char act = GetKeyAct(enumKey1); + if (act == enumKeyPress) + { + if (status == 1) + { + spin2(); + status = 0; + } + else + { + spin1(); + status = 1; + } + } +} + +void main() +{ + EXTInit(enumEXTPWM); + MySTC_Init(); + DisplayerInit(); + LedPrint(0); + KeyInit(); + SetEventCallBack(enumKeyPress, select); + spin1(); + while (1) + { + MySTC_OS(); + } +}