From a60eec580093bb32da0238450849b41c0075ccd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=A1=E5=9D=82=E6=98=B4?= Date: Tue, 25 Mar 2025 13:16:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=9A=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E4=B8=89=20=E7=AC=AC=E4=BA=8C=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework3/.eide/eide.json | 4 +++- homework3/src/test1.c | 2 +- homework3/src/test2.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 homework3/src/test2.c diff --git a/homework3/.eide/eide.json b/homework3/.eide/eide.json index 777d686..8889ee1 100644 --- a/homework3/.eide/eide.json +++ b/homework3/.eide/eide.json @@ -18,7 +18,9 @@ }, "targets": { "Debug": { - "excludeList": [], + "excludeList": [ + "src/test1.c" + ], "toolchain": "Keil_C51", "compileConfig": { "options": "null" diff --git a/homework3/src/test1.c b/homework3/src/test1.c index 6eb37cb..2a555b1 100644 --- a/homework3/src/test1.c +++ b/homework3/src/test1.c @@ -13,7 +13,7 @@ void test1() ADDR0 = 0; while (true) { - P2 = ~(0x80 >> cnt); + P2 = ~(0x01 << cnt); Delay(20000); cnt++; if (cnt >= 8) { diff --git a/homework3/src/test2.c b/homework3/src/test2.c new file mode 100644 index 0000000..d49bb73 --- /dev/null +++ b/homework3/src/test2.c @@ -0,0 +1,31 @@ +// test2.c +// 右向流水灯(流水速度逐渐加快) +#include "homework3.h" + +unsigned char cnt = 0; + +void test2() +{ + ENLED = 0; + ADDR3 = 1; + ADDR2 = 1; + ADDR1 = 1; + ADDR0 = 0; + i = 100000; + + while (true) { + P2 = ~(0x80 >> cnt); + Delay(i); + cnt++; + if (cnt >= 8) { + cnt = 0; + } + if (i > 5000) { + i -= 1000; + } + } +} +void main() +{ + test2(); +} \ No newline at end of file