Hi
ich habe einen Code der eigentlich auch funktioniert.
Wollte ihn jetzt auf einen Attiny2313 schreiben, nur dummerweise reicht der SRAM nicht aus.
Vor allem das 'config dcf' scheint ausschlaggebend zu sein. Gibt es irgendwo eine Angabe wieviel SRAM 'config dcf' verschlingt?
Besteht noch Hoffnung den Code so abzuändern dass es passt?
Beim Complieren sagt er bereits bei "Dim Dig0 As Byte , Dig1 As Byte..." er seit out of SRAM.
Code:
$regfile = "attiny2313.dat"
$crystal = 1000000
Config Dcf77 = Pinb.3 , Timer = 1 , Debug = 1 , Inverted = 1 , Timer1sec = 1 , Check = 1
Config Timer0 = Timer , Prescale = 1 , Edge = Rising
Config Date = Dmy , Separator = .
Config Portb.0 = Output ' din
Config Portb.1 = Output ' cs
Config Portb.2 = Output ' clk
Max_din Alias Portb.0
Max_cs Alias Portb.1
Max_clk Alias Portb.2
Set Max_din ' cs, din, clk = high
Set Max_cs
Set Max_clk
Dim Ausgabe As String * 8
Ausgabe = "_-HELP-_"
Dim I As Integer
Dim Sec_old As Byte , Dcfsec_old As Byte
Dim Merker As Byte
Declare Sub Max7221datenout(daten As Word)
Declare Sub Max7221zeichenlesen
Declare Sub Max7221init
Dim Led_operation As Word
Dim Dig0 As Byte , Dig1 As Byte , Dig2 As Byte , Dig3 As Byte , Dig4 As Byte , Dig5 As Byte , Dig6 As Byte , Dig7 As Byte
Gosub Max7221init
Gosub Max7221zeichenlesen
Enable Interrupts
Dim Zaehler As Byte
Zaehler = 0
Sec_old = 99 : Dcfsec_old = 99 ': DCF_Debug_Timer = 0
Do
For I = 1 To 78 'vorher 78
Waitms 10
If Sec_old <> _sec Then
Exit For
End If
If Dcfsec_old <> Dcf_sec Then
Exit For
End If
Next
Waitms 220
Sec_old = _sec
If Dcf_sec <> Dcfsec_old Then Gosub Led
Dcfsec_old = Dcf_sec
If _sec = 50 And Merker = 0 Then Gosub Schaltsekunde 'Softuhr ist 3 Sec. zu schnell
If _sec > 55 Then Merker = 0
If Zaehler <= 8 Then
Ausgabe = Time$
Dig7 = &B01100110
Else
Ausgabe = Date$
Dig7 = &B01001000
End If
Incr Zaehler
If Zaehler = 11 Then Zaehler = 0
Gosub Max7221zeichenlesen
Loop
Schaltsekunde:
Merker = 1
_sec = _sec - 3
Return
Led:
'Toggle Portc.0
Return
End 'end program
Sub Max7221zeichenlesen
Dim Db_zeiger As Word
Dim Tl As Byte
Dim Ez As Byte
Dim Dat(8) As Byte
Dim Einzelzeichen As String * 1
Tl = Len(ausgabe)
Dim A As Byte , B As Byte
B = 1
For A = 1 To Tl
Einzelzeichen = Mid(ausgabe , A , 1)
Ez = Asc(einzelzeichen)
Select Case Ez
Case 32 : Db_zeiger = 0
Case 45 : Db_zeiger = 1
Case 48 : Db_zeiger = 2
Case 49 : Db_zeiger = 3
Case 50 : Db_zeiger = 4
Case 51 : Db_zeiger = 5
Case 52 : Db_zeiger = 6
Case 53 : Db_zeiger = 7
Case 54 : Db_zeiger = 8
Case 55 : Db_zeiger = 9
Case 56 : Db_zeiger = 10
Case 57 : Db_zeiger = 11
Case 69 : Db_zeiger = 12
Case 72 : Db_zeiger = 13
Case 76 : Db_zeiger = 14
Case 80 : Db_zeiger = 15
Case 95 : Db_zeiger = 16
Case Else Db_zeiger = 0
End Select
Dat(b) = Lookup(db_zeiger , Zeichensatz)
Incr B
Next A
B = 8
For A = 0 To 7
Dig0.a = Dat(b).6
Dig1.a = Dat(b).5
Dig2.a = Dat(b).4
Dig3.a = Dat(b).3
Dig4.a = Dat(b).2
Dig5.a = Dat(b).1
Dig6.a = Dat(b).0
Decr B
Next A
Led_operation = &B0000000100000000 + Dig0 'dig0
Call Max7221datenout(led_operation)
Led_operation = &B0000001000000000 + Dig1 'dig1
Call Max7221datenout(led_operation)
Led_operation = &B0000001100000000 + Dig2 'dig2
Call Max7221datenout(led_operation)
Led_operation = &B0000010000000000 + Dig3 'dig3
Call Max7221datenout(led_operation)
Led_operation = &B0000010100000000 + Dig4 'dig4
Call Max7221datenout(led_operation)
Led_operation = &B0000011000000000 + Dig5 'dig5
Call Max7221datenout(led_operation)
Led_operation = &B0000011100000000 + Dig6 'dig6
Call Max7221datenout(led_operation)
Led_operation = &B0000100000000000 + Dig7 'dig7
Call Max7221datenout(led_operation)
Return
End Sub
Sub Max7221init
Led_operation = &B0000110000000000 ' shutdown mode normal operation
Call Max7221datenout(led_operation)
Led_operation = &B0000110000000001 ' shutdown mode normal operation
Call Max7221datenout(led_operation)
Led_operation = &B0000100100000000 ' decode mode code b for digit 7-0
Call Max7221datenout(led_operation)
Led_operation = &B0000101000000000 ' intensity | &H0A01 = 2/16 | &H0A09 = 10/16 | &H0A0F = 15/16(max on)
Call Max7221datenout(led_operation)
Led_operation = &B0000101100000111 ' scan limit digit 0-7
Call Max7221datenout(led_operation)
Return
End Sub
Sub Max7221datenout(daten As Word)
Max_cs = 0
Shiftout Max_din , Max_clk , Daten , 1 , 16
Max_cs = 1
Waitms 10
End Sub
Zeichensatz: 'Segment A,B,C,D,E,F,G - sortiert nach ASCII
Data 0 'SPACE DEC32
Data 1 '- DEC45
Data 126 '0 DEC48
Data 48 '1 DEC49
Data 109 '2 DEC50
Data 121 '3 DEC51
Data 51 '4 DEC52
Data 91 '5 DEC53
Data 95 '6 DEC54
Data 112 '7 DEC55
Data 127 '8 DEC56
Data 115 '9 DEC57
Data 79 'E DEC69
Data 55 'H DEC72
Data 14 'L DEC76
Data 103 'P DEC80
Data 8 '_ DEC95
Lesezeichen