AVR Embedded Tutorial - Analog Read/de
From Lazarus wiki
Jump to navigationJump to search
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.