AVR Embedded Tutorial - Analog Read/de

From Lazarus wiki
Revision as of 00:10, 14 November 2017 by Mathias (talk | contribs) (Created page with "{{Translate}} {{Warning| In Arbeit}} =Analog Read= ==Vorwort== Wie man die UART ansteuert, steht hier: * UART ''UARTInit'' und ''UARTSend...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Template:Translate

Warning-icon.png

Warnung: In Arbeit

Analog Read

Vorwort

Wie man die UART ansteuert, steht hier:

  • UART UARTInit und UARTSendString(...

code

const
  REFS0 = 6;
  ADPS0 = 0;
  ADPS1 = 1;
  ADPS2 = 2;


  procedure ADC_Init;
  begin
    ADMUX := (1 shl REFS0);
    ADCSRA := %111 or (1 shl ADEN);
  end;

  function ADC_Read(Port: byte): integer;
  begin
    ADMUX := (1 shl REFS0) or (Port and $0F);
    ADCSRA := ADCSRA or (1 shl ADSC);
    while (ADCSRA and (1 shl ADSC)) <> 0 do begin
    end;

    Result := ADC;
  end;

var
  Data: integer;
  s: string[10];

begin

  // UART inizialisieren
  UARTInit;

  // ADC
  ADC_Init;

  asm
           Sei end;
  repeat
    Data := ADC_Read(0);
    str(Data: 6, s);
    UARTSendString(s);
  until 1 = 2;
end.