diff --git a/FinalTerm/.eide/eide.json b/FinalTerm/.eide/eide.json index 781ec5a..6fce81f 100644 --- a/FinalTerm/.eide/eide.json +++ b/FinalTerm/.eide/eide.json @@ -18,7 +18,9 @@ }, "targets": { "Debug": { - "excludeList": [], + "excludeList": [ + "src/main.c" + ], "toolchain": "Keil_C51", "compileConfig": { "options": "null" diff --git a/FinalTerm/schematic.pdsprj b/FinalTerm/schematic.pdsprj new file mode 100644 index 0000000..e5561b6 Binary files /dev/null and b/FinalTerm/schematic.pdsprj differ diff --git a/FinalTerm/src/51pins/51pins.h b/FinalTerm/src/51pins/51pins.h new file mode 100644 index 0000000..1b34546 --- /dev/null +++ b/FinalTerm/src/51pins/51pins.h @@ -0,0 +1,70 @@ +/* + * @name: 51pins.h + * @author: msksbr + * @date: 2025-05-29 + * @description: defines the 7 segs chars and pins for LEDs, 74HC138 and buttons + * @usage: #include "REG52.H" + */ +#include + +// 74HC138 pins (P1) +// controller pins +sbit ADDR0 = P1 ^ 0; // to A(A0) +sbit ADDR1 = P1 ^ 1; // to B(A1) +sbit ADDR2 = P1 ^ 2; // to C(A2) +// enable pins +sbit ADDR3 = P1 ^ 3; // to E1 +sbit ENLED = P1 ^ 4; // to E2 & E3 + +// 7seg chars(P2) +unsigned char code seg7chars[] = { + 0xFC, // 0: a b c d e f + 0x60, // 1: b c + 0xDA, // 2: a b g e d + 0xF2, // 3: a b g c d + 0x66, // 4: f g b c + 0xB6, // 5: a f g c d + 0xBE, // 6: a f g c d e + 0xE0, // 7: a b c + 0xFE, // 8: all segments + 0xF6, // 9: a b c d f g + 0xEE, // A: a b c e f g + 0x3E, // B: c d e f g + 0x9C, // C: a d e f + 0x7A, // D: b c d e g + 0x9E, // E: a d e f g + 0x8E, // F: a e f g + 0x02, // dp: decimal point + 0x00, // all on + 0xFF // blank: all off +}; + +// switch 74HC138 +void switch138(unsigned char channel) +{ + // @subsection: turn DEC channel to 3 BIN bits + bit A0 = channel & 0x01; + bit A1 = (channel >> 1) & 0x01; + bit A2 = (channel >> 2) & 0x01; + // @subsection: enable 74HC138 + ADDR3 = 1; + ENLED = 0; + // @subsection: set 74HC138 pins + ADDR0 = A0; + ADDR1 = A1; + ADDR2 = A2; +} + +// timer by ms based on timer0 +void delay_ms(unsigned int ms) +{ + TMOD = 0x01; + for (; ms > 0; ms--) { + TH0 = 0xFC; + TL0 = 0x66; + TR0 = 1; + while (!TF0); + TR0 = 0; + TF0 = 0; + } +} \ No newline at end of file diff --git a/FinalTerm/src/test/testPNP.c b/FinalTerm/src/test/testPNP.c new file mode 100644 index 0000000..69627f7 --- /dev/null +++ b/FinalTerm/src/test/testPNP.c @@ -0,0 +1,25 @@ +/* + * @name: testPNP.c + * @author: msksbr + * @date: 2025-05-29 + * @description: test PNP power supply. + */ + +#include +#include "../51pins/51pins.h" + +unsigned char currentChannel = 0; + +void main() +{ + while (1) { + P2 = 0x00; + switch138(currentChannel); + if (currentChannel == 7) { + currentChannel = 0; + } else { + currentChannel++; + } + delay_ms(1); + } +} \ No newline at end of file