...ich habe den C.Code mal umgesetzt und habe das ganze an mein Oszi angeschlossen. (ein Pin direkt an den ext. Triggger und den anderen über den 2Bit-R2R an den 1. Kanal)
EDIT:
Aktualisierter Code-> Ich habe die Sub 'Zustand' entfernt und verwende jetzt einen 16Mhz Quarz.
Ich bekomme bis jetzt nur zwei Punkte (einen auf Low und der andere auf Middle) und die Nullinie angezeig.Code:'------------[Meta]------------------------------------------------------------- $regfile = "m32def.dat" $crystal = 16000000 $hwstack = 32 $swstack = 10 $framesize = 40 '------------[Lib für KS108-gLCD]----------------------------------------------- $lib "glcdKS108.lbx" '------------[GLCD Config]------------------------------------------------------ Config Graphlcd = 128 * 64sed , Dataport = Portc , Controlport = Porta , Ce = 1 , Ce2 = 2 , Cd = 3 , Rd = 4 , Reset = 0 , Enable = 5 Cls Setfont Font6x8 ' Forn laden '------------[Const & Variabeln definieren]------------------------------------- Const Max_digit = 6 ' Sechs Zeichen müssen dargestellt werden Const Slots = Max_digit * 3 + 4 ' Anzahl der Zeitschlitze -> 2 für Header, 3 pro Zeichen, 2 für Trailer Dim Ss As Byte ' Sekunde Dim Mn As Byte ' Minute Dim Hh As Byte ' Stunde Dim Line_(slots) As Byte Dim Didx As Byte ' Zeitschlitz (timeslot) counter Dim Fidx As Byte ' Frame counter Dim I As Byte Dim Display_(max_digit) As Byte ' anzeigbare Zeichen Dim S As Byte Dim P As Byte Dim Tmp As Byte ' temp '------------[Ports definieren]------------------------------------------------- '------------[AVR-Atmega32-Pins]-------------------------------------------- 'PortA.0 = | PortB.0 = | PortC.0 = | PortD.0 = 'PortA.1 = | PortB.1 = | PortC.1 = | PortD.1 = 'PortA.2 = | PortB.2 = | PortC.2 = | PortD.2 = DCF-77 'PortA.3 = | PortB.3 = | PortC.3 = | PortD.3 = Status-LED 'PortA.4 = | PortB.4 = | PortC.4 = | PortD.4 = R2R-Bit.2 'PortA.5 = | PortB.5 = | PortC.5 = | PortD.5 = R2R-Bit.1 'PortA.6 = | PortB.6 = | PortC.6 = | PortD.6 = Trigger 'PortA.7 = | PortB.7 = | | PortD.7 = '------------------------------------------------------------------------------- '----[Trigger-Output]----------------------------------------------------------- Config Pind.6 = Output Trigger Alias Portd.6 '----[2Bit R2R DAU]------------------------------------------------------------- Config Pind.5 = Output Bit1 Alias Portd.5 '----[2Bit R2R DAU]------------------------------------------------------------- Config Pind.4 = Output Bit2 Alias Portd.4 '----[Status-LED]--------------------------------------------------------------- Config Pind.3 = Output Led Alias Portd.3 Led = 1 ' LED einschalten '----[Taster_Stunde]------------------------------------------------------------ Config Pinb.0 = Input Taster_hr Alias Pinb.0 Portb.0 = 1 ' Pullup aktivieren '----[Taster_Minute]------------------------------------------------------------ Config Pinb.1 = Input Taster_mn Alias Pinb.1 Portb.1 = 1 ' Pullup aktivieren '----[DCF_77-Input]------------------------------------------------------------- Config Pinb.2 = Input Dcf_77 Alias Pinb.2 Portb.2 = 0 ' Pullup deaktivieren '------------[Timer1 konfigurieren]--------------------------------------------- Config Timer1 = Timer , Prescale = 256 On Timer1 Ontimer Const Pre = 43200 Load Timer1 , Pre '------------[Interrupts aktivieren]-------------------------------------------- Enable Interrupts ' Interrupts aktivieren '------------[Programm]--------------------------------------------------------- '------------[Start]------------------------------------------------------------ Cls ' ------[TEST]------------------------------------------------------------------ ' Zustand 90 : Lcdat 1 , 0 , "Zero " : Wait 1 ' Zero ' Zustand 76 : Lcdat 1 , 0 , "Lower " : Wait 1 ' Lower ' Zustand 77 : Lcdat 1 , 0 , "Middle" : Wait 1 ' Middle ' Zustand 72 : Lcdat 1 , 0 , "High " : Wait 1 ' High ' Lcdat 1 , 0 , "run.." Enable Timer1 Do ' Lcdat 1 , 0 , Hh , ":" , Mn . ":" , Ss ' ----------[Buffer leeren]----------------------------------------------------- For I = 1 To Slots : Line_(i) = 0 : Next For I = 1 To Max_digit : Display_(i) = 0 : Next ' ----------[Prepare display buffer]-------------------------------------------- Display_(6) = Ss Mod 10 ' Sekunden Display_(5) = Ss / 10 Display_(4) = Mn Mod 10 ' Minuten Display_(3) = Mn / 10 Display_(2) = Hh Mod 10 ' Stunden If Hh > 9 Then Display_(1) = Hh / 10 Else Display_(1) = 10 ' blank first, digit if Zero ' ----------[Tasterabfrage zum einstellen der Uhrzeit]-------------------------- Debounce Taster_mn , 0 , Incr_mn , Sub ' Minuten einstellen Debounce Taster_hr , 0 , Incr_hr , Sub ' Stunden einstellen Mn = Mn Mod 60 ' prevent minute overflow Hh = Hh Mod 24 ' prevent hours overflow ' ----------[Prepare time slot flags]------------------------------------------- For I = 1 To Max_digit ' Für jedes Zeichen S = Lookup(display_(i) , Septseg) ' Get 7 segment encoding Tmp = Lookup(i , Sidx) ' get pointer to time slot, left part of the digit P = Line_(tmp) '======================================================================= P.0 = S.0 ' Bit.0 | Segment A P.1 = S.6 ' Bit.6 | Segment G P.2 = S.3 ' Bit.3 | Segment D P.6 = S.4 ' Bit.4 | Segment E P.7 = S.5 ' Bit.5 | Segment F '======================================================================= Incr P ' Next slot ,center part of the digit '======================================================================= P.0 = S.0 ' Bit.0 | Segment A (fortsetzung) P.1 = S.6 ' Bit.6 | Segment G (fortsetzung) P.2 = S.3 ' Bit.3 | Segment D (fortsetzung) Incr P ' Next slot, right part of the digit P.6 = S.2 ' Bit.6 | Segment B P.7 = S.1 ' Bit.1 | Segment C '======================================================================= Next I ' ------[Teil des ISR Interruptsprung aus dem C-Code]--------------------------- '---------------------------------------------------------------------- If Line_(didx).6 = 1 And Line_(didx).7 = 1 Then ' if full vertical bar Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 'Low,High,Low,High -> 16 mal durchlaufen damit die Seitenleiste breiter wird… Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 1 Elseif Line_(didx).6 = 1 Then ' if lower vertical bar Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 'Mid,Low,Mid,Low -> 16 mal durchlaufen damit die Seitenleiste breiter wird… Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 0 : Bit2 = 1 Elseif Line_(didx).7 = 1 Then ' if upper vertical bar Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 : Bit1 = 1 : Bit2 = 0 : Bit1 = 1 : Bit2 = 1 End If If Didx = 7 Then ' Stunden : Minuten separator Bit1 = 0 : Bit2 = 1 : Waitus 10 ' Low Bit1 = 1 : Bit2 = 0 : Waitus 10 ' Mid Elseif Didx = 14 Then ' Minuten : Sekunden separator If Timer1 < 22336 Then ' Blink ~0.5 Hz -> (65536- const pre) Bit1 = 0 : Bit2 = 1 : Waitus 10 ' Low Bit1 = 1 : Bit2 = 0 : Waitus 10 ' Mid End If End If Select Case Fidx ' Je nach Frameindex Case 0 : If Line_(didx).0 = 1 Then ' obere Linie Bit1 = 1 : Bit2 = 1 ' High Else Bit1 = 0 : Bit2 = 0 ' Zero End If Case 1 : If Line_(didx).1 = 1 Then ' mittlere Linie Bit1 = 1 : Bit2 = 0 ' Mid Else Bit1 = 0 : Bit2 = 0 ' Zero End If Case 2 : If Line_(didx).2 = 1 Then ' untere Linie Bit1 = 0 : Bit2 = 1 ' Low Else Bit1 = 0 : Bit2 = 0 ' Zero End If End Select Incr Didx ' nächster Slot If Didx = Slots Then ' letzter Slot ? Didx = 0 ' lösche Slot Trigger = 1 ' Oszi triggern (EIN) Incr Fidx ' nächster Frame If Fidx = 3 Then ' letzter Frame ? Fidx = 0 ' lösche Frame Trigger = 0 ' Oszi triggern (AUS) End If End If ' --------------------------------------------------------------------- Loop '======[Adjust-Time Labels]===================================================== Incr_mn: Ss = 0 Incr Mn Return Incr_hr: Ss = 0 Incr Hh Return '------------[Timer Interrupt Sprungmarke]-------------------------------------- Ontimer: '---------------------------------------------------------------------- Toggle Led Incr Ss ' nächste Sekunde If Ss = 60 Then ' letzte Sekunde in der Minute ? Ss = 0 ' lösche Sekunde Incr Mn ' nächste Minute If Mn = 60 Then ' letzte Minute in der Stunde ? Mn = 0 ' lösche Minute Incr Hh ' nächste Stunde If Hh = 24 Then ' letzte Stunde am Tag? Hh = 0 ' lösche Stunde End If End If End If '---------------------------------------------------------------------- Load Timer1 , Pre Return '---------[Ende]---------------------------------------------------------------- End '----[Segment defenitionen]----------------------------------------------------- Septseg: Data &H3F , &H06 , &H5B , &H4F , &H66 , &H6D , &H7D , &H07 , &H7F , &H6F , &H00 ' 0 1 2 3 4 5 6 7 8 9 - 'BiN: 0111111,0000110,1011011,1001111,1100110,1101101,1111101,0000111,1111111,1101111,0000000 ' gfedcba,gfedcba,gfedcba,gfedcba,gfedcba,gfedcba,gfedcba,gfedcba,gfedcba,gfedcba,gfedcba '----[Slot Index für Zeichen-Start]--------------------------------------------- Sidx: Data 1 , 4 , 8 , 11 , 15 , 18 $include "font6x8.font" ' Fontdatei einfügen
Den Part
aus dem C.Code habe ich mit in die Hauptschleife einbezogen. Hier könnte der Fehler liegen.Code:if(line[dIdx].F6 && line[dIdx].F7) // if full vertical bar { LOW, HIGH, LOW, HIGH ; 16 mal durchlaufen damit die Seitenleiste breiter wird. LOW, HIGH, LOW, HIGH ; LOW, HIGH, LOW, HIGH ; LOW, HIGH, LOW, HIGH ; LOW, HIGH, LOW, HIGH ; LOW, HIGH, LOW, HIGH ; LOW, HIGH, LOW, HIGH ; LOW, HIGH, LOW, HIGH ; } else if(line[dIdx].F6) // if lower vertical bar { MID, LOW, MID, LOW ; MID, LOW, MID, LOW ; MID, LOW, MID, LOW ; MID, LOW, MID, LOW ; MID, LOW, MID, LOW ; MID, LOW, MID, LOW ; MID, LOW, MID, LOW ; MID, LOW, MID, LOW ; } else if(line[dIdx].F7) // if upper vertical bar { MID, HIGH, MID, HIGH ; MID, HIGH, MID, HIGH ; MID, HIGH, MID, HIGH ; MID, HIGH, MID, HIGH ; MID, HIGH, MID, HIGH ; MID, HIGH, MID, HIGH ; MID, HIGH, MID, HIGH ; MID, HIGH, MID, HIGH ; } if(dIdx == 7) // hour : minute separator { LOW, Delay10us() ; MID, Delay10us() ; } else if(dIdx == 14) // minute : second separator { if(scaler < MAX_SCALER / 2) // blink 0.5 Hz { LOW, Delay10us() ; MID, Delay10us() ; } } switch(fIdx) // depending on frame index { case 0: // upper line if(line[dIdx] & 1) ( HIGH ; ) else ( ZERO ; ) break ; case 1: // middle line if(line[dIdx] & 2) ( MID ; ) else { ZERO ; ) break ; case 2: // lower line if(line[dIdx] & 4) { LOW ; } else { ZERO ; } break ; } dIdx++ ; // next slot if (dIdx == SLOTS) // last slot ? { dIdx = 0 ; // clear slot TRIGGER = 1 ; // triggers the scope fIdx++ ; // next frame if(fIdx == 3) // last frame ? { fIdx = 0 ; ) // clear frame TRIGGER = 0 ; ) // end trigger
Kann sich das mal jemand anschauen?
DANKE!
Gruß MaXX





Zitieren

Lesezeichen