reset: homework4 code

This commit is contained in:
2025-04-14 12:15:02 +08:00
parent 58c39aa710
commit 7fadeb5d2a
6 changed files with 10 additions and 65 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
"targets": { "targets": {
"Debug": { "Debug": {
"excludeList": [ "excludeList": [
"src/test2.c" "src/test1.c"
], ],
"toolchain": "Keil_C51", "toolchain": "Keil_C51",
"compileConfig": { "compileConfig": {
+9 -1
View File
@@ -24,7 +24,15 @@
"editor.insertSpaces": true, "editor.insertSpaces": true,
"editor.tabSize": 4, "editor.tabSize": 4,
"editor.autoIndent": "advanced" "editor.autoIndent": "advanced"
} },
"cSpell.words": [
"ENSEG",
"SEGB",
"SEGC",
"SEGD",
"SEGE",
"SEGF"
]
}, },
"extensions": { "extensions": {
"recommendations": [ "recommendations": [
Binary file not shown.
-22
View File
@@ -1,22 +0,0 @@
// homework4.h
/*
* this file defines the pin numbers for the LED and 38 transistors.
*/
#include <REG52.H>
sbit D_ADDR0 = P1 ^ 0;
sbit D_ADDR1 = P1 ^ 1;
sbit D_ADDR2 = P1 ^ 2;
sbit D_ADDR3 = P1 ^ 3;
sbit ENLED = P1 ^ 4;
sbit D1 = P2 ^ 0;
sbit D2 = P2 ^ 1;
sbit D3 = P2 ^ 2;
sbit D4 = P2 ^ 3;
sbit D5 = P2 ^ 4;
sbit D6 = P2 ^ 5;
sbit D7 = P2 ^ 6;
sbit D8 = P2 ^ 7;
-33
View File
@@ -1,33 +0,0 @@
// test1.c
// 通过定时器实现以0.5Hz的频率闪烁一个小灯
#include "homework4.h"
unsigned char cnt = 0; // log timer T0 overflow counts
void main()
{
ENLED = 0;
D_ADDR3 = 1;
D_ADDR2 = 1;
D_ADDR1 = 1;
D_ADDR0 = 0;
TMOD = 0x01; // timer T0 mode 1, 16-bit timer
TH0 = 0XB8;
TL0 = 0X00;
TR0 = 1; // timer T0 run
while (1) {
if (TF0 == 1) { // timer T0 overflow
TF0 = 0; // clear timer T0 overflow flag
TH0 = 0xB8; // reload timer T0 value
TL0 = 0x00;
cnt++; // log timer T0 overflow counts
if (cnt >= 50) {
cnt = 0; // clear log timer T0 overflow counts
D1 = ~D1; // toggle LED
}
}
}
}
-8
View File
@@ -1,8 +0,0 @@
// test2.c
// 点亮数码管段b和c,让数码管显示一个数字1;
#include "homework4.h"
void main() {
}