Interrupt mit ATmega8

tilo
 
Avatar
 
Betreff:

Interrupt mit ATmega8

 · 
Gepostet: 11.10.2010 - 08:07 Uhr  ·  #1
Hi,

ich hab schonmal was zu meinem Problem gepostet aber nicht wirklich hilfe bekommen also versuch ichs nochmal.
Also ich bin Anfänger und versuch grad ein kleines Programm mit ein Interrupt zuschreiben.Will aber weder aufm Simulator noch sonst wie funktionieren und hab schon alles mögliche ausprobiert und kann den Fehler einfach nicht finden.Das Programm soll bei einem Signal an PinD.2 ein Interrupt auslösen und in diesem soll eine LED eingeschaltet werden.

Code

program Interrupts;

{$NOSHADOW}
{ $WG} {global Warnings off}


Device = mega8, VCC=5;
{ $BOOTRST $00C00} {Reset Jump to $00C00}

Define_Fuses
Override_Fuses;
NoteBook = A;
COMport = USB;
LockBits0 = [];
FuseBits0 = [];
FuseBits1 = [];

Import SysTick ;
From System Import ;


Define
ProcClock = 8000000; {Hertz}
SysTick = 10; {msec}
StackSize = $0032, iData;
FrameSize = $0032, iData;

Implementation

{$IDATA}

{--------------------------------------------------------------}
{ Type Declarations }

type


{--------------------------------------------------------------}
{ Const Declarations }

{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}
var


{--------------------------------------------------------------}
{ functions }
procedure InitPorts;
begin
DDRD := %01100000; //set PinD.5/6 as output
GICR := GICR OR %11000000; //INT0/INT1 activation
MCUCR:= MCUCR or %00001111; //The rising edge of INT1/INT0 generates an interrupt request
GIMSK:= GIMSK or %11000000;
end InitPorts;

Interrupt INT0;
begin
Toggle(PortD.5);
end;
{--------------------------------------------------------------}
{ Main Program }
{$IDATA}

begin
InitPorts;
EnableInts;

loop
nop;
endloop;
end Interrupts. //Programm heißt Interrupts


tilo
Merlin
Administrator
Avatar
Geschlecht:
Alter: 25
Beiträge: 1474
Dabei seit: 03 / 2005
Betreff:

Re: Interrupt mit ATmega8

 · 
Gepostet: 11.10.2010 - 09:44 Uhr  ·  #2
Hi tilo.

Zitat

PinD.5:=1;


What the purpose of this statement?

Also why are you setting D2, D3 as outputs? They are interrupts 0 and 1 which should be inputs. I am sure, however, you did not do that last time.

I assume that you have external pull/ups or pull/downs when the input is not driven, or that it is driven both high and low? If not you must either add these to your circuit or operate the internal pull-ups.

Regards

Merlin
rh
Administrator
Avatar
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: Interrupt mit ATmega8

 · 
Gepostet: 11.10.2010 - 14:50 Uhr  ·  #3
Hallo tilo,

da geht garnichts:
PinD.5:=1;
1. ist PinX immer ein Input, also muss es heissen: PortD.5:= 1;
2. wäre es besser so:
Toggle(PortD.5);
Damit wird bei jedem Interrupt dieser Port Pin umgeschaltet.

Das Init des Interrupts habe ich nicht geprüft...

rolf
tilo
 
Avatar
 
Betreff:

Re: Interrupt mit ATmega8

 · 
Gepostet: 12.10.2010 - 08:13 Uhr  ·  #4
Ich erklär jetzt noch ma genauer mein Problem.
Undzwar das Programm an sich funktioniert ja ich krieg keine Fehlermehldung oder so im Simulator.Nur ist das Problem das er nicht den Interrupt auslöst also INTF setzt wenn ich es ausprobieren will, egal wie ich die Register setze ob nun Int1 oder Int0 oder auf welche Flanke er reagieren soll oder sonstwas.
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   78   92 · Page-Gen-Time: 0.032632s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI