From b4a3a188fee2c0ea935fdbec2b7ac83e42718398 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:11:20 +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=B8=80=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework3/homework3.code-workspace | 85 +++++++++++++++--------------- homework3/src/homework3.h | 29 ++++++++++ homework3/src/test1.c | 28 ++++++++++ 3 files changed, 100 insertions(+), 42 deletions(-) create mode 100644 homework3/src/homework3.h create mode 100644 homework3/src/test1.c diff --git a/homework3/homework3.code-workspace b/homework3/homework3.code-workspace index 8c192af..7177d54 100644 --- a/homework3/homework3.code-workspace +++ b/homework3/homework3.code-workspace @@ -1,44 +1,45 @@ { - "folders": [ - { - "path": "." - } - ], - "settings": { - "files.autoGuessEncoding": true, - "C_Cpp.default.configurationProvider": "cl.eide", - "C_Cpp.errorSquiggles": "disabled", - "files.associations": { - ".eideignore": "ignore", - "*.a51": "a51", - "*.h": "c", - "*.c": "c", - "*.hxx": "cpp", - "*.hpp": "cpp", - "*.c++": "cpp", - "*.cpp": "cpp", - "*.cxx": "cpp", - "*.cc": "cpp" - }, - "[yaml]": { - "editor.insertSpaces": true, - "editor.tabSize": 4, - "editor.autoIndent": "advanced" - } - }, - "extensions": { - "recommendations": [ - "cl.eide", - "keroc.hex-fmt", - "xiaoyongdong.srecord", - "hars.cppsnippets", - "zixuanwang.linkerscript", - "redhat.vscode-yaml", - "IBM.output-colorizer", - "cschlosser.doxdocgen", - "ms-vscode.vscode-serial-monitor", - "alefragnani.project-manager", - "cl.stm8-debug" - ] + "folders": [ + { + "path": "." } -} \ No newline at end of file + ], + "settings": { + "files.autoGuessEncoding": true, + "C_Cpp.default.configurationProvider": "cl.eide", + "C_Cpp.errorSquiggles": "disabled", + "files.associations": { + ".eideignore": "ignore", + "*.a51": "a51", + "*.h": "c", + "*.c": "c", + "*.hxx": "cpp", + "*.hpp": "cpp", + "*.c++": "cpp", + "*.cpp": "cpp", + "*.cxx": "cpp", + "*.cc": "cpp", + "REG52.H": "cpp" + }, + "[yaml]": { + "editor.insertSpaces": true, + "editor.tabSize": 4, + "editor.autoIndent": "advanced" + } + }, + "extensions": { + "recommendations": [ + "cl.eide", + "keroc.hex-fmt", + "xiaoyongdong.srecord", + "hars.cppsnippets", + "zixuanwang.linkerscript", + "redhat.vscode-yaml", + "IBM.output-colorizer", + "cschlosser.doxdocgen", + "ms-vscode.vscode-serial-monitor", + "alefragnani.project-manager", + "cl.stm8-debug" + ] + } +} diff --git a/homework3/src/homework3.h b/homework3/src/homework3.h new file mode 100644 index 0000000..40c72c1 --- /dev/null +++ b/homework3/src/homework3.h @@ -0,0 +1,29 @@ +// homework3.h +// 这个文件是用来存放本实验中用到的宏定义和函数的 +#include + +#define true 1 +#define false 0 + +unsigned int i = 0; + +sbit D1 = P2 ^ 7; +sbit D2 = P2 ^ 6; +sbit D3 = P2 ^ 5; +sbit D4 = P2 ^ 4; +sbit D5 = P2 ^ 3; +sbit D6 = P2 ^ 2; +sbit D7 = P2 ^ 1; +sbit D8 = P2 ^ 0; + +sbit ADDR0=P1^0; +sbit ADDR1=P1^1; +sbit ADDR2=P1^2; +sbit ADDR3=P1^3; +sbit ENLED=P1^4; + + +void Delay(unsigned int t) +{ + while (t--); +} \ No newline at end of file diff --git a/homework3/src/test1.c b/homework3/src/test1.c new file mode 100644 index 0000000..6eb37cb --- /dev/null +++ b/homework3/src/test1.c @@ -0,0 +1,28 @@ +// test1.c +// 左向流水灯 +#include "homework3.h" + +unsigned char cnt = 0; + +void test1() +{ + ENLED = 0; + ADDR3 = 1; + ADDR2 = 1; + ADDR1 = 1; + ADDR0 = 0; + + while (true) { + P2 = ~(0x80 >> cnt); + Delay(20000); + cnt++; + if (cnt >= 8) { + cnt = 0; + } + } +} + +void main() +{ + test1(); +} \ No newline at end of file