Hallo,
ich versuch schon ne weile nen Hardwareinterrupt bei nem ATmega8
auszulösen und es will einfach nicht funktionieren.Das hier ist mein
Programmcode und ist in Pascal programmiert.
var
i,:byte;
{--------------------------------------------------------------}
{ functions }
procedure InitPorts;
begin
DDRD := %01100000;
DDRB := %00000000;
PortB:= %00000000;
GICR := %11000011;
MCUCR:= %00001100;
sreg := %10000000;
end InitPorts;
Interrupt Int0;
begin
i:=PinB.1;
sdelay(100);
if i=1 then
PortD.5:=1;
endif;
end;
Interrupt Int1;
begin
i:=PinB.1;
sdelay(100);
if i=1 then
PortD.5:=1;
endif;
end;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
InitPorts;
EnableInts;
loop
endloop;
end Interrupts.
mfg Thomas
Die Interrupteingäne sind: (INT0) PD2 (INT1) PD3 mach doch erst mal die Routinen einfach: Interrupt Int0; begin PortD.5:=1; PortD.6:=0; end; Interrupt Int1; begin PortD.5:=0; PortD.6:=1; end;
Ich kann zwar kein Pascal mehr (lang ists her ...), aber was mir trotzdem auffällt: Wozu setzt Du IVSEL und IVCE in GICR (soweit habe ich mir die Mühe gemacht, die Bits rückwärts aufzudröseln, weiter nicht mehr. Nimm bitte ihre symbolischen Namen)? Du machst die Zuweisung nur einmal, somit dürfte sie ohne weiteren Einfluss bleiben, aber sinnlos ist es allemal. Wäre die Zuweisung tatsächlich wirksam, würde sie zudem nur dann keinen Schaden anrichten, wenn Du speziell für einen Bootloader o.ä. kompilieren würdest. In Deinem Programm löscht niemand PortD.5, wenn es einmal gesetzt ist. Ist das beabsichtigt?
Hi mein lauffähiger Code(schnipsel) sieht so aus: (mikroPascal/ATmega32) Procedure Int0_ISR(); org IVT_ADDR_INT0; begin // ... end; //------------------------------------------------- Procedure Int1_ISR(); org IVT_ADDR_INT1; begin // ... end; //------------------------------------------------- // MAIN // ISC01=1, ISC00=0: The falling edge of INT0 generates an interrupt request. MCUCR.ISC00 := 0; // \ call ISR on MCUCR.ISC01 := 1; // / falling edge GICR.INT0 := 1; // global interrupt control register // ISC11=1, ISC10=0: The falling edge of INT1 generates an interrupt request. MCUCR.ISC10 := 0; // \ call ISR on MCUCR.ISC11 := 1; // / falling edge GICR.INT1 := 1; // global interrupt control register // setup timer1, enable interrupts TOIE1_bit := 1; // Timer1 overflow interrupt enable TCCR1B := %010; // Start timer with 8 prescaler SREG_I_bit := 1; // global Interrupt enable // while ... end.
Hier ist nochmal mein Prog jetzt n bischen ordentlicher.
Und das mit PortD soll so sein ich will erstmal nur sehen ob der
Interrupt funktioniert.
procedure InitPorts;
begin
DDRD := %01100000;
GICR := %01000000; //INT0 activation
MCUCR:= %00001100; //The rising edge of INT1 generates interrupt
request
sreg := %10000000; //global Interrupt enable
end InitPorts;
Interrupt Int0;
begin
PortD.5:=1;
end;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}
begin
InitPorts;
EnableInts;
loop
endloop;
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.