Hello, could someone please help me? I'm pretty new at this. I tried to make a simple watchdog that resets my server when it freezes. I have made a windows program which sets one bit of the parallel port every minute for a second. The Attiny 2313 is programmed that is resets the server when this doesn't happen for more than ten minutes. I have connected the attiny 2313 to the following pins: +5V --- to +5V on the mainboard connector GND --- to one of the GNDs from the parallel port PB0 --- (as input) to the pin on the parallel port which is set by the windows program; and a 10k resistor which is connected to GND on the other end PB7 --- (as output) to the reset pin on the mainboard connector Behavior: when the windows program isn't running, the server resets after 11 minutes (as it should) When the windows program is running, the server runs for about 20 minutes and then resets (it shows that i use the correct pin of the parallel port, at least). Maybe someone has an idea what i did wrong? Here is the c-code:
1 | #include <avr/io.h> |
2 | #include <util/delay.h> |
3 | #include <avr/pgmspace.h> |
4 | #include <inttypes.h> |
5 | |
6 | int main(void) { |
7 | |
8 | int timer; |
9 | int value; |
10 | int oldvalue; |
11 | |
12 | const int TIMERMAX = 6000; |
13 | |
14 | DDRB = 0xFE; // 11111110 - PB0 is input |
15 | |
16 | PORTB = 0; |
17 | |
18 | oldvalue = 0; timer = 0; |
19 | |
20 | while (1) { |
21 | if (bit_is_set(PINB,0)) { value = 1; } else { value = 0; } |
22 | if (oldvalue != value) { |
23 | oldvalue = value; |
24 | timer = 0; |
25 | }
|
26 | timer++; |
27 | _delay_ms(100); |
28 | |
29 | if (timer > TIMERMAX) { // no change on PB0 for more than 10 min. |
30 | PORTB = 0x80; // set PB7 to 1 |
31 | _delay_ms(100); |
32 | PORTB = 0; |
33 | timer = 0; |
34 | }
|
35 | } // while |
36 | }
|
Thank You very much for Your help, Peter