Hanging on a problem using interrupts with an Mega16... I want to decode a DCF77 signal (german time signal from AM). For this I use INT2 which will be called on falling edge. This works. In the IRQ2-routine I activate Timer0 with IRQ on Overflow. This works not :-( The overflow IRQ will never be called.
If I activate Timer outside from IRQ2 everything works fine.
See the code (it is no complete code, just the way...)
Code: Select all
procedure Int_2; org INT2addr;
Begin
GICR.5:=0; // INT2 Disable
Multip:=0; // Timer-Overlow Counter
TIMSK.1:=1; // ENable Timer0
While Pinb.2=0 do Delay_us(1); //Wait until Portb.2 gets High
TIMSK.1:=0; // Stop Timer0
t:=TCNT0; // Now got the time Portb.2 was low.
TT:=(Multip*255)+T; // Multip was Increased each time a timer overflow occured.
WordToStr(TT,strTT);
Usart1_Write_Text(strTT);
GICR.5:=1; // INT2 Enable
end;
Procedure Timer_1; org OVF0addr;
Inc(Multip);
end;
begin
MCUCSR.6:=0; // INT2 Config auf falling edge
GICR.5:=1; // INT2 Enable
DDRb.2:=0;
Portb.2:=0;
TCCR0 := 5; // start timer with 1024 prescaler
Multip:=0;
SREG.7:= 1; // enable global interrupt
If False then Begin // Dummy calls for Linker
ByteToStr(T,StrT);
WordToStr(T,StrT);
USART1_Write_Text('dummy');
end;
While True do nop;
end.
(TCNT1H and TCNT1L have always the same values and an overflow nerver occurs)
I'm soooo excited on the next release/beta of mP which will be hopefully published still this month :-) Ok, next month would be early enough if you can give me a workaround for the above problem ;-)
TIA
Sascha