A.Schilling
14.06.2007, 14:32
Harware ist Atmega2560, RN-KeyLCD (über RS232), CC2net-Ram Interface (SAA1064) und CC2net-Ram Device mit 4MBit (und Batterie), Software Bascom 1.1.8.5. Ich bin Neueinsteiger bei Amtel (vorher CControll, da hatte ich den Speicher im Griff). Meine Versuche bringen leider kein Ergebnis beim Auslesen des EEProm (selbst wenn nichts geschrieben wird, es liegen 255000 Integerwerte im Speicher von der CControl her). Der Code ist der letzte Stand nach verschiedenen Versuchen. Das Programm läuft ohne Pause durch. Das Auslesen von ERR nach jedem Schritt beim Lesen / Schreiben bringt ein Ergebnis <> 1 (für die bessere Übersicht aus diesem Quelltext entfernt). Problem ist, das beim Auslesen des Speicher mit I2crbyte "Value" immer 0 ist. Nach 2 Tagen Code-basteln also die Frage, was mache ich falsch, bzw. was fehlt noch.
$prog , 255 , &B11011001 ,
$regfile = "m2560def.dat"
$hwstack = 82
$framesize = 68
$swstack = 68
$crystal = 16000000
$baud = 9600
$lib "i2c_twi.lbx"
Config Sda = Portd.1 'SDA und SCL definiere
Config Scl = Portd.0 'für TWI-Bus-Konfiguration
I2cinit
Config Twi = 100000 ' wanted clock frequency
Declare Sub Write_eeprom(byval Adres As Word , Byval Wert As Byte)
Declare Sub Read_eeprom(byval Adres As Word )
Dim Temp As Word
Dim Adres As Word
Dim Value As Byte
Const Addressw = &H70
Const Addressr = &H71
'Sonstiges
Dim X As Word
Dim Wert As Byte
Print Chr(12);
Do
Wert = 0
Print Chr(12);
For X = 76 To 255
Wert = Wert + 1
Print Chr(27) ; Chr(79) ; Chr(1) ; Chr(1);
Print "Adresse " ; X ; " " ; Wert ;
Call Write_eeprom(x , Wert)
Call Read_eeprom(x , Value )
Next X
Loop
End
Sub Write_eeprom(byval Adres As Word , Byval Wert As Byte)
Disable Interrupts
I2cstart 'start condition
I2cwbyte Addressw 'slave address
I2cwbyte Adres 'asdress of EEPROM
I2cwbyte Wert 'value to write
I2cstop 'stop condition
Enable Interrupts
Waitms 10
End Sub
Sub Read_eeprom(byval Adres Word , Value As Byte)
Disable Interrupts
I2cstart 'generate start
I2cwbyte Addressw
I2cwbyte Adres 'address of EEPROM
I2cstart 'repeated start
I2cwbyte Addressr 'slave address (read)
I2crbyte Value , Nack 'read byte
I2cstop
Enable Interrupts
Waitms 10 'generate stop
Print Chr(27) ; Chr(79) ; Chr(1) ; Chr(2);
Print "Wert " ; Value ; 'das Problem Value immer 0
End Sub
$prog , 255 , &B11011001 ,
$regfile = "m2560def.dat"
$hwstack = 82
$framesize = 68
$swstack = 68
$crystal = 16000000
$baud = 9600
$lib "i2c_twi.lbx"
Config Sda = Portd.1 'SDA und SCL definiere
Config Scl = Portd.0 'für TWI-Bus-Konfiguration
I2cinit
Config Twi = 100000 ' wanted clock frequency
Declare Sub Write_eeprom(byval Adres As Word , Byval Wert As Byte)
Declare Sub Read_eeprom(byval Adres As Word )
Dim Temp As Word
Dim Adres As Word
Dim Value As Byte
Const Addressw = &H70
Const Addressr = &H71
'Sonstiges
Dim X As Word
Dim Wert As Byte
Print Chr(12);
Do
Wert = 0
Print Chr(12);
For X = 76 To 255
Wert = Wert + 1
Print Chr(27) ; Chr(79) ; Chr(1) ; Chr(1);
Print "Adresse " ; X ; " " ; Wert ;
Call Write_eeprom(x , Wert)
Call Read_eeprom(x , Value )
Next X
Loop
End
Sub Write_eeprom(byval Adres As Word , Byval Wert As Byte)
Disable Interrupts
I2cstart 'start condition
I2cwbyte Addressw 'slave address
I2cwbyte Adres 'asdress of EEPROM
I2cwbyte Wert 'value to write
I2cstop 'stop condition
Enable Interrupts
Waitms 10
End Sub
Sub Read_eeprom(byval Adres Word , Value As Byte)
Disable Interrupts
I2cstart 'generate start
I2cwbyte Addressw
I2cwbyte Adres 'address of EEPROM
I2cstart 'repeated start
I2cwbyte Addressr 'slave address (read)
I2crbyte Value , Nack 'read byte
I2cstop
Enable Interrupts
Waitms 10 'generate stop
Print Chr(27) ; Chr(79) ; Chr(1) ; Chr(2);
Print "Wert " ; Value ; 'das Problem Value immer 0
End Sub