AVR Embedded Tutorial - GPIO-Interrupt/de

From Lazarus wiki
Revision as of 22:33, 11 November 2017 by Mathias (talk | contribs) (Created page with "{{Translate}} {{Warning| In Arbeit}} =GPIO Interrupt= ==Vorwort== Wie man die GPIO und UART ansteuert, steht hier: * AVR Embedded Tutorial - Simple GPIO on and off output...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Template:Translate

Warning-icon.png

Warnung: In Arbeit

GPIO Interrupt

Vorwort

Wie man die GPIO und UART ansteuert, steht hier:

  • GPIO
  • UART UARTInit und UARTSendString(...

INT0 + INT1

kommt noch

Pin Change Interrupt

Terminal Ausgabe

Gibt den Pin-Status auf einem Terminal aus.

  procedure WritePort(p: byte);
  begin
    UARTSendString('PB' + char(p + 48) + ' : ');
    if PinB and (1 shl p) = (1 shl p) then begin
      UARTSendString('HIGH   ');
    end else begin
      UARTSendString('LOW    ');
    end;
  end;

Interrupt

Wird bei einer Änderung eines Pines ausgelöst.

  procedure PC_Int0_Interrupt; public Name 'PCINT0_ISR'; interrupt;
  var
    i: byte;
  begin
    UARTSendString(#27'[0;0H'); // Cursor home
    for i := 0 to 3 do begin
      WritePort(i);
    end;
  end;

Pin Change Interrupt initialisieren

const
  inPorts = %00001111; // PCINT0 + PCINT1 + PCINT2 + PCINT3
begin
  DDRB := 0;
  PORTB := inPorts; // PullUp

  // UART inizialisieren
  UARTInit;

  // PC_INT0 aktivieren
  PCICR := (1 shl PCIE);
  PCMSK0 := inPorts;

  // Interrupt aktivieren
  asm
           Sei end;
  repeat
  until 1 = 2;
end.