AD Wandler mega8

tilo
 
Avatar
 
Subject:

AD Wandler mega8

 · 
Posted: 27.10.2010 - 08:33  ·  #1
Hallo,

ich versuch grad nen kleinen AD-Wandler auf meinem AVR-Evaluations-Board hinzukriegen.Will aber nicht so richtig funktionieren.Hab einen einstellbaren Wiederstand an PortC.0 und AREF gesetzt.
Der mega8 soll eine LED zum Leuchten bringen wenn er eine Spannung an PortC.0 hat.
Hoffe mir kann jemand sogen was ich falsch gemacht hab und sagen was noch fehlt.

Code
procedure Init;
begin
ADCSRA:=%11101110;   //free running mode; presc 64
ADMUX :=%11000000;  //interner Spannung 2.56V;PortC.0 meßender Kanal
end;

{--------------------------------------------------------------}
{ Main Program }
{$IDATA}

begin

  Init;
  EnableInts;
  loop

a:= GetAdc (1);

IF a>=0  THEN PortD.5:=1;

endif;

  endloop;
end AD_Wandler.


mfg tilo
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: AD Wandler mega8

 · 
Posted: 27.10.2010 - 13:40  ·  #2
A couple of points.

GetADC is always >= 0.

There is no way of turning PortD.5 off.

You don't seem to set port D to an output.

Regards

Merlin.
Selected quotes for multi-quoting:   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.
MySQL Queries: 15 · Cache Hits: 13   50   63 · Page-Gen-Time: 0.017762s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI