E-LAB Computers
 

Interrupt Frage

  • 1
  • 2
  • Page 1 of 2
TheBeginner
Schreiberling
Avatar
Gender: n/a
Location: Wunsiedel Bayern
Posts: 799
Registered: 06 / 2013
Subject:

Interrupt Frage

 · 
Posted: 28.05.2026 - 09:57  ·  #1
Guten Morgen, ich suche gerade eine Möglichkeit 3 Interrupt
C1 C2 C3
beim Xmega abzufragen der bei Aufsteigender und Absteigender Flanke auslöst.
Ich denke das ist dieses -> bothedges;

Kann jmd helfen ?

Gruß Frank


Good morning, I'm looking for a way to query three interrupts (C1, C2, C3) on the Xmega that trigger on both rising and falling edges.

I think this is what's needed -> bothedges;

Can anyone help?

Regards, Frank
miparo
Moderator
Avatar
Gender:
Location: Germany
Posts: 1029
Registered: 09 / 2007
Subject:

Re: Interrupt Frage

 · 
Posted: 28.05.2026 - 12:00  ·  #2
Moin Frank,
mit bothedges liegst du richtig, es gibt ein Demo dazu XMega_PortInt.

Wobei BeepClick im Interrupt natürlich sinnfrei ist eher kurz und knapp im Int.

miparo
TheBeginner
Schreiberling
Avatar
Gender: n/a
Location: Wunsiedel Bayern
Posts: 799
Registered: 06 / 2013
Subject:

Re: Interrupt Frage

 · 
Posted: 28.05.2026 - 12:15  ·  #3
Hallo miparo, genau das habe ich mir auch angeschaut.
Aber wie lese ich jetzt PinC1 / PinC2 / PinC3 aus.

Im Demo wird nur PortIntD = 0 ausgelesen also ich denke PinD.0
PortIntD = 0, PullUp, bothedges; // pin0 used, Pullup on, both edge

Das hier ist Interrupt CallBack
Procedure PortIntD;
begin
BeepClick;
inc(PD);
end;

Ich habe auch was von einen Dispatcher gelesen, aber KA was das genau ist.

Ich habe auch schon versucht
PortIntD = 1,2,3 PullUp, bothedges; // pin0 used, Pullup on, both edge

Und auch Procedure
PortIntD1;
begin
BeepClick;
inc(PD);
end;

Aber da bekomme ich Probleme.

Gruß Frank
miparo
Moderator
Avatar
Gender:
Location: Germany
Posts: 1029
Registered: 09 / 2007
Subject:

Re: Interrupt Frage

 · 
Posted: 28.05.2026 - 13:49  ·  #4
dann den PinChangeInt benutzen dazu define PCintCmask = $07 ; ....... deiner 3 Pins und
Procedure PCintC0;
Procedure PCintC1;
Procedure PCintC2 definieren ;

Weiß allerdings nicht , ob der auf beide Flanken geht.
TheBeginner
Schreiberling
Avatar
Gender: n/a
Location: Wunsiedel Bayern
Posts: 799
Registered: 06 / 2013
Subject:

Re: Interrupt Frage

 · 
Posted: 28.05.2026 - 15:48  ·  #5
Ne miparo das haut nicht hin. Ich habe viel getestet.

// PCintCmask = $14, PullUp, bothedges;
// PCintCmask = %00001110, PullUp, bothedges;
PCintCmask = 14, PullUp, rising;// bothedges;

Ich bekomme immer diese Meldung.
Habe auch schon in den pdf Datein nach PCintCmask gesucht,
aber nichts gefunden.

Gruß Frank
Attachments
Interrupt Frage
File name: errorjpg.jpg
File size: 7.75 KB
Title:
Downloaded: 85
miparo
Moderator
Avatar
Gender:
Location: Germany
Posts: 1029
Registered: 09 / 2007
Subject:

Re: Interrupt Frage

 · 
Posted: 28.05.2026 - 16:00  ·  #6
Du würfelst PortInt und PCint durcheinander!
Die PCint Parameter erwarten nur ein Byte.

Compiler Handbuch Seite 81.
TheBeginner
Schreiberling
Avatar
Gender: n/a
Location: Wunsiedel Bayern
Posts: 799
Registered: 06 / 2013
Subject:

Re: Interrupt Frage

 · 
Posted: 28.05.2026 - 18:16  ·  #7
Genau miparo, ich darf nicht PCint nehmen sondern
PortIntC = 3, PullUp, bothedges;
Und damit wird wirklich Pin3 von Port C abgefragt.

Dann bekomme ich auch alles richtig angzeigt
Code

Procedure PortIntC;             // Interrupt CallBack
begin
  if EndZ = true then
    GSwitchView(6);
    gDrawCircle (0, 0, 10, 255, byte(clRED));
    gFillCircle (0, 0, 10, byte(clRED));
    GSwitchView(0);
  else
    GSwitchView(6);
    gDrawCircle (0, 0, 10, 255, byte(clGREEN));
    gFillCircle (0, 0, 10, byte(clGREEN));
    GSwitchView(0);
  endif;
end;

Das haut 100% hin.

Aber was ist mit Pin1 und Pin2

PortIntCmask geht nicht.

Ich brauche für meine Abfrage -> bothedges;

Gruß Frank
TheBeginner
Schreiberling
Avatar
Gender: n/a
Location: Wunsiedel Bayern
Posts: 799
Registered: 06 / 2013
Subject:

Re: Interrupt Frage

 · 
Posted: 29.05.2026 - 16:23  ·  #8
Ich habe es jetzt anders gemacht und damit habe ich ruhe.

Code

  PortIntD       = 0, PullUp, bothedges;  
  PortIntC       = 1, PullUp, bothedges;  
  PortIntF       = 4, PullUp, bothedges; 



Gruß Frank
miparo
Moderator
Avatar
Gender:
Location: Germany
Posts: 1029
Registered: 09 / 2007
Subject:

Re: Interrupt Frage

 · 
Posted: 29.05.2026 - 18:08  ·  #9
Hi Frank,
auf einem Port gehts auch, sollte etwas so tun:
Natürlich kein PortIntC define mehr nötig

Code

{ Const Declarations }
const
  PIN1_bm: byte = 2;
  PIN2_bm: byte = 4;
  PIN3_bm: byte = 6;

Var
    IntLastState: byte;

procedure PortInt1Init;
const
  PinMask: byte = (PIN1_bm or PIN2_bm or PIN3_bm);
begin
  PORTC.DIRCLR:= PinMask;   // Input
  PIN1CTRLC:= $18;               // PullUp, bothedges
  PIN2CTRLC:= $18;
  PIN3CTRLC:= $18;
  INT1MASKC:= PinMask;      // Bitmask Pin 1,2,3
  INTCTRLC:= 1;
  INTFLAGSC:= 2;
  PMICCTRL:= 1;             //  Low Level Interrupt Executing bit mask.
  IntLastState:= PinC;
end;


procedure PORTC_INT1;             // Interrupt CallBack
var
  currState, XorState : byte;
begin
  currState:= PinC;
  XorState:= currState xor IntLastState;

  // PinC.1
  if (XorState and PIN1_bm) > 0 then
    if (currState and PIN1_bm) > 0 then  // wenn State benötigt wird 
       // steigende Flanke

    else
      // fallende Flanke
    endif;
  endif;

  // PinC.2
  if (XorState and PIN2_bm) > 0 then
    // if (currState and PIN2_bm) > 0 then
  endif;

  // PinC.3
  if (XorState and PIN3_bm) > 0 then

  endif;
  IntLastState:= currState;
end;



///  ---- main 
  EnableInts($87);
  BeepOut(2000, 5);
  PortInt1Init();
....



miparo
TheBeginner
Schreiberling
Avatar
Gender: n/a
Location: Wunsiedel Bayern
Posts: 799
Registered: 06 / 2013
Subject:

Re: Interrupt Frage

 · 
Posted: 29.05.2026 - 19:34  ·  #10
Ich Danke dir, kann ich Morgen mal testen, aber nicht mehr heute.

Ich melde mich wieder.


Gruß Frank
miparo
Moderator
Avatar
Gender:
Location: Germany
Posts: 1029
Registered: 09 / 2007
Subject:

Re: Interrupt Frage

 · 
Posted: 30.05.2026 - 00:23  ·  #11
Habs allerdings noch nicht getestet, ansonsten mal im Debugger schauen, ob Int1 dann on ist aber so tudelt es beim Xmega .
PortInt macht nichts anderes aktiviert allderdings nur einen Pin.
TheBeginner
Schreiberling
Avatar
Gender: n/a
Location: Wunsiedel Bayern
Posts: 799
Registered: 06 / 2013
Subject:

Re: Interrupt Frage

 · 
Posted: 25.07.2026 - 13:39  ·  #12
Hallo miparo, sorry aber ich bin jetzt erst dazu gekommen deinen Code zu testen.
Meine Endschalter hängen aber jetzt an PF5 PF6 PF7

ich habe schon versucht deinen Code umzuschreiben, aber das haut nicht hin.
Könntest du helfen ?

Griß Frank
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quote:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.