Probleme nach Update der Atmega8 Version

E.Faber
 
Avatar
 
Subject:

Probleme nach Update der Atmega8 Version

 · 
Posted: 19.08.2010 - 07:38  ·  #1
Guten Morgen,

nachdem ich gestern das neuste Update der Atmega8 Version eingespielt habe,
funktioniert mein Dallas 1-Wire Temperaturfühler nicht mehr. Bisher gab es
nie Probleme den Temperaturfühler auszulesen bzw. zu erkennen.
Da das einzige kritische dabei das Einhalten der Timeslots ist, vermute ich da
einen Zusammenhang.
Nach dem installieren der Download-Version funktioniert alles wieder wie gehabt.
Da ich keine Möglichkeit sehe, das Temperaturauslesen im Simulator zu testen,
ist die Frage, wie ich an das Problem herangehen könnte, ausser auf das Update
zu verzichten.

Viele Grüße

Elmar
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Probleme nach Update der Atmega8 Version

 · 
Posted: 19.08.2010 - 13:30  ·  #2
Hallo Elmar,
das dürfte ein Seiten Effekt der XMega Unterstützung sein :'(
Aber ohne ein kleines Test Programm das das Problem aufzeigt habe ich keine Chance dahinter zu kommen. Sorry.

rolf
E.Faber
 
Avatar
 
Subject:

Re: Probleme nach Update der Atmega8 Version

 · 
Posted: 19.08.2010 - 13:43  ·  #3
Hallo Rolf,

ja das dachte ich mir schon - ich hab aber leider keine Ahnung wie ich das machen könnte.
Ich bekomme eben als Ergebnis immer nur Mist bzw. einen Fehlercode.
Ich habe mal die meiner Meinung nach kritischen Stellen angehängt.
Die einzige Stelle, wo ich eben Probleme sehe sind die Funktionen
uDelay() und uDelay_1(). Wenn die TimeSlots nicht stimmen, bekomme ich
kein korrektes Ergebnis. Wie ich aber dafür ein kleines Testprogramm ohne Hardware
hinbekomme - :'( :'( :'(

Code
//--------------------------------------------------------------------------
// READ_BYTE - Reads a byte from the one-wire bus.
//--------------------------------------------------------------------------
Function ReadByte: Byte;
//--------------------------------------------------------------------------
var
  i:     Byte;
  Value: Byte;
begin
  for i := 0 to 7 do
    // initiate read bit time slot
    OneWireDir  := DirOutput;
    OneWireLine := LowLine;
    uDelay_1(1);
    OneWireLine := HighLine;
    OneWireDir  := DirInput;
    uDelay_1(15);
    // reads byte in, one byte at a time and then shifts it left
    If (OneWirePin = True) then
      incl(Value, i);
    else
      excl(Value, i);
    endif;
    uDelay(11); // wait for rest of timeslot
  endfor;

  return (Value);
end ReadByte;

//--------------------------------------------------------------------------
// READ_Bit - Reads a bit from the one-wire bus.
//--------------------------------------------------------------------------
Function ReadBit : byte;
//--------------------------------------------------------------------------
VAR stat : boolean ;
begin            // initiate read bit time slot
  OneWireDir  := DirOutput;
  OneWireLine := LowLine;
  uDelay_1(1);
  OneWireLine := HighLine;
  OneWireDir  := DirInput;
  uDelay_1(15);
  stat := OneWirePin;
  udelay(11);    // wait for rest of timeslot
  IF stat THEN
    Return(1);
  ELSE
    RETURN(0);
  ENDIF;
end ReadBit;

//--------------------------------------------------------------------------
// Write_Byte - Writes a byte to the one-wire bus.
//--------------------------------------------------------------------------
Procedure WriteByte (Value: Byte);
//--------------------------------------------------------------------------
var
  i, temp :  Byte;
begin
  for i:=0 to 7 do
    // initiate write bit time slot
    OneWireDir  := DirOutput;
    OneWireLine := LowLine;
    uDelay_1(1);
    if ((Value shr i) and $01) > 0 then // shifts val right 'i' spaces
      OneWireLine := HighLine;          // return DQ high if write 1
    endif;
    uDelay(11); // hold value for remainder of timeslot
    OneWireLine := HighLine;
    OneWireDir  := DirInput;
    // uDelay_1(10);    // ????????
  endfor;
end WriteByte;

//--------------------------------------------------------------------------
// Write_Bit - Writes a bit to the one-wire bus.
//--------------------------------------------------------------------------
Procedure WriteBit(Value : byte);
//--------------------------------------------------------------------------
Begin
  OneWireDir  := DirOutput;
  OneWireLine := LowLine;
  uDelay_1(1);       // 15us WriteSlot leave low
  If value = 1 then
    OneWireLine := HighLine;
  EndIf ;
  udelay(11); // If wite 0 THEN hold LOW for remainder of timeslot
  OneWireLine := HighLine;
  OneWireDir  := DirInput;
  // uDelay_1(10); //10us for each bit
End;


Code
//--------------------------------------------------------------------------
// ReadTemperature
//--------------------------------------------------------------------------
Function ReadTemperature(Sensor : Byte) : Int8;
//--------------------------------------------------------------------------
var
   TLsb,  // return temperature value
   crc,
   TMsb  : Byte;
   i,k   : Byte;
   ftemp : Int8;
begin

  {$IFNDEF Simulator}
  If OneWireReset THEN       // select the DS1820
    WriteByte(cmdMatchROM);  // MatchCode
    For i := 0 to 7 do       // send RomNumber
      WriteByte(RomArray[Sensor,i]);
    Endfor;
  Else
    // Fehler...
    Return(-127);
  Endif;

  WriteByte(cmdReadScratchpad); // Read Scratch Pad
  for k := 0 to 8 do            // read the data 9 bytes
    RomGetA[k] := ReadByte;
    crc := DoCrcByte(RomGetA[k]);
  endfor;



Grüße

Elmar
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Probleme nach Update der Atmega8 Version

 · 
Posted: 19.08.2010 - 13:51  ·  #4
Hallo Elmar,

das hilft mir absolut nicht weiter. Bitte reduzieren Sie Ihr Programm auf das minimalste so dass es trotzdem noch komplett ist und bei Ihnen den Fehler zeigt.
Dann bitte vial email.

rolf
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: 14   79   93 · Page-Gen-Time: 0.022642s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI