Das Programm lässt sich mit der 2.0.7.4 kompilieren. Ich musste nur gegen ersetzen, sowie gegen ersetzen.
Code:
$crystal = 1000000 '1 MHz, Damit auch die Software davon weiss
$regfile = "ATtiny26.dat" 'Wir benutzen einen Tiny26
$noramclear
Const Eeprom_adress_w = &HA0 'Basisadresse des verwendeten EEPROMs 24C64A = &HA0 / 24C256 = &HA0
Const Eeprom_adress_r = Eeprom_adress_w + 1 'Nicht aendern!
Dim Eeprom_size As Word '
Dim Last_icadr As Word '
Dim Measured_bytes As Byte '
Dim Bversion As Byte '
Dim Icadr As Word At &H74 'Adresse im I2C-EEProm
Dim Icadrlo As Byte At &H74 Overlay '
Dim Icadrhi As Byte At &H75 Overlay '
Dim Collected As Word At &H78 'Anzahl gespeicherter Datensätze im akt. Block
Dim Collectedlo As Word At &H78 Overlay '
Dim Collectedhi As Word At &H79 Overlay '
Dim Wtemp0 As Word At &H7C '16Bit temporär
Dim Wtemp0lo As Byte At &H7C Overlay '
Dim Wtemp0hi As Byte At &H7D Overlay '
Dim Wtemp1 As Word At &H7E '16Bit temporär
Dim Btemp0 As Byte '
Dim Btemp1 As Byte '
Dim Stemp As String * 16 'String temporär
'Config & Init ----------------------------------------------
Ddra = &B00000000 'Ddra Input
Porta = &B11111111 'pull-up
Ddrb = &B01100000 'Ddrb.0 Input SDA (Mini-Datenlogger)
'DDrb.1 Input
'DDrb.2 Input SCL (Mini-Datenlogger)
'DDrb.3 Input Button
'DDrb.4 Input Seriell
'DDrb.5 Output Seriell
'DDrb.6 Output Reset (Mini-Datenlogger)
'DDrb.7 Input (Reset)
Portb = &B01001000 'Portb.0 SDA (Mini-Datenlogger)
'Portb.1
'Portb.2 SCL (Mini-Datenlogger)
'Portb.3 pull-up für Button
'Portb.4 seriell
'Portb.5 seriell
'Portb.6 Reset (Mini-Datenlogger)
'Portb.7
Config Sda = Portb.0 'Ports fuer die I2C-Schnittstelle
Config Scl = Portb.2
'I2cinit 'wird mit DDRB= und PORTB= miterledigt
'Reset Portb.0 (Sda)
'Reset Portb.2 (Scl)
'Reset Ddrb.0 (Sda)
'Reset DDrb.2 (Scl)
Open "COMB.5:9600,8,N,1,INVERTED" For Output As #1 'Port für serielle Ausgabe
'Set Ddrb.5
'Reset Portb.5
'Program ----------------------------------------------------
_read_i2c: ' '
I2cstop '
Waitms 500 '
Icadr = 0 '
Gosub Read_eeprom '
Measured_bytes = Wtemp0lo '
Bversion = Wtemp0hi '
Gosub Read_eeprom '
Eeprom_size = Wtemp0 '
Print #1 , "no connect"
If Bversion = 0 Then Goto _read_i2c
If Bversion = 255 Then Goto _read_i2c
If Measured_bytes = 0 Then Goto _read_i2c
If Measured_bytes = 255 Then Goto _read_i2c
If Eeprom_size = 0 Then Goto _read_i2c
Shift Eeprom_size , Left , 8 '
Eeprom_size = Eeprom_size + 255 '
Print #1 , "MiniLogger;"
Print #1 , ";" ; Bversion ; ";" ; Measured_bytes ; ";" ; Eeprom_size ; ";"
Shift Measured_bytes , Right , 1 'lesen erfolgt word-weise
Last_icadr = Eeprom_size - 4 '
Last_icadr = Last_icadr - Measured_bytes '
Gosub Read_eeprom '
Do 'Beginn Hauptschleife
Gosub Read_eeprom '
Print #1 , ";"
Print #1 , Wtemp0 ; ";"
Collected = Wtemp0 '
For Wtemp1 = 1 To Collected 'Datensätze lesen
If Icadr > Last_icadr Then
Collected = 0
Exit For '
End If
For Btemp1 = 1 To Measured_bytes
Gosub Read_eeprom
Print #1 , ";" ; Wtemp0hi ; ";" ; Wtemp0lo ;
Next Btemp1
Print #1 , ";"
Next Wtemp1
Loop Until Collected = 0 'Ende Hauptschleife
Do '
Loop '
'I2C-Routinen
'-----------------------------------
Read_eeprom: '
I2cstart 'generate start
I2cwbyte Eeprom_adress_w 'slave adsress
I2cwbyte Icadrhi 'address of EEPROM
I2cwbyte Icadrlo 'address of EEPROM
I2cstart 'repeated start
I2cwbyte Eeprom_adress_r 'slave address (read)
I2crbyte Wtemp0hi , Ack 'read byte
I2crbyte Wtemp0lo , Nack 'read byte
I2cstop 'generate stop
Incr Icadr
Incr Icadr
Return
Out of SRAM Space kann darauf hindeuten, dass in den Optionen zu hohe Stackwerte eingetragen sind, welche dann genommen werden, wenn im Programmcode nichts angegeben ist.
Lesezeichen