Hi Frank,
auf einem Port gehts auch, sollte etwas so tun:
Natürlich kein PortIntC define mehr nötig
{ 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
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
