Forum: µC & Digital Electronics Watchdog with ATTiny 2313 not working

von Peter (Guest)

Rate this post
0 useful
not useful
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:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
#include <inttypes.h>

int main(void) {

  int timer;
  int value;
  int oldvalue;

  const int TIMERMAX = 6000;

  DDRB = 0xFE; // 11111110 - PB0 is input

  PORTB = 0;  

  oldvalue = 0; timer = 0;

  while (1) {
    if (bit_is_set(PINB,0)) { value = 1; } else { value = 0; }
    if (oldvalue != value) {
       oldvalue = value;
       timer = 0;
    if (timer > TIMERMAX) {  // no change on PB0 for more than 10 min.
       PORTB = 0x80;    // set PB7 to 1      
       PORTB = 0;
       timer = 0;
  } // while

Thank You very much for Your help,

von MagIO (Guest)

Rate this post
0 useful
not useful
Sorry ... I don't use AVRs currently, but as nobody else replies .. here 
are my 2 cents:

I'd simply use the good old LED-debugger to watch what the AVR thinks it 
sees on the parallel port. Did you check the LPT with a scope?

I remember that there are different LPT-interface modes you can choose 
in the BIOS setup. Maybe there's a problem with the mode you use?

Good luck!

von Peter (Guest)

Rate this post
0 useful
not useful
thank You for Your answer! I've tried the LEDs. A LED connected to the 
concerning pin of the LPT does go on and off, just as the windows 
program dictates (on for 1 second, off for a minute).

To test the avr, I put a led to the output port (PB7) and decreased the 
inactivity interval to a few seconds.
As long as I touched a wire with +5V to the input port (PB0) often 
enough, nothing happened, when I didn't the LED would be on for about 
1/10 of a second, just like it should.

Of course, I didn't try it for 20 minutes...

Does it have to be exactly +5V on the input port? I think the LPT of my 
servers delivers something between 3V and 4V.
Do I have a problem with the 10k resistor? Should I activate the 
internal pullup of the input instead?

Thank You,

von MagIO (Guest)

Rate this post
0 useful
not useful
I'd make sure that the parallel port is running in SPP mode, not EPP or 

Whether the 10k resistor is a problem or not can be checked with LED 
debugger as well. Use another port pin and set it similar to your value 
variable. Then you see what the AVR sees on the input-pin.

I don't see a problem in the program.

von Peter (Guest)

Rate this post
0 useful
not useful
Thank You!
I will try changing the lpt settings.
Great idea with the value variable! Maybe that will help me!

Thank You,


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.