#include <90s2313.h> // External Interrupt 0 service routine interrupt [EXT_INT0] void ext_int0_isr(void) { PORTD.3 = 0; //Notaus aktiv Luft aus } // Declare your global variables here #define TEIL_EINGELEGT PIND.0 #define NOTAUS PIND.2 #define NOTAUS_AN PORTD.3 #define SCHRAUBEN PORTD.4 #define HOCHFAHREN PORTD.5 #define RAUF_LED PORTB.0 #define RUNTER_LED PORTB.1 #define NOTAUS_LED PORTB.2 // timouts in "timer"-Einheiten. timer laeuft mit 10Hz = 100ms #define TIMEOUT 1800 unsigned long timer; /* Called automatically on TIMER1 output compare */ interrupt [5] void timer1_output_compare(void) { timer++; } void main(void) { // Declare your local variables here unsigned long runter_timer; // Input/Output Ports initialization // Port D initialization // Func6=In Func5=Out Func4=Out Func3=Out Func2=In Func1=In Func0=In // State6=T State5=0 State4=0 State3=0 State2=T State1=T State0=T PORTD=0x00; DDRD=0x38; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped TCCR0=0x00; TCNT0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer 1 Stopped // Mode: Normal top=FFFFh // OC1 output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge TCCR1A=0x00; // TCCR1B=0x00; // timer mit Output Compare, Vorteiler 1024 TCCR1B = 0x0D; TCNT1H=0x00; TCNT1L=0x00; OCR1H= (16 >> 8); OCR1L= 16 & 0xFF; // OCR1H= 0; // OCR1L= 1; // External Interrupt(s) initialization // INT0: On // INT0 Mode: Rising Edge // INT1: Off GIMSK=0x40; MCUCR=0x03; GIFR=0x40; // timer auf 0 setzen vor dem start timer = 0; // Timer(s)/Counter(s) Interrupt(s) initialization // (nur Timer 1 Output Compare aktiviert) TIMSK=0x40; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; #asm sei #endasm while (1) { if (TEIL_EINGELEGT == 0) { runter_timer = timer; SCHRAUBEN = 1; } if((SCHRAUBEN == 1) && ((timer - runter_timer) > TIMEOUT)) { SCHRAUBEN = 0; } } }