At90s2313 i EEPROM I2C AT24C02
-
Jimi Hendrix
- -
- Posty: 12
- Rejestracja: 29 lip 2005, 18:33
- Lokalizacja: Poznań
At90s2313 i EEPROM I2C AT24C02
Otóż mam z tą parką taki problem - napisałem programik testowy, zapisujący i odczytujący po bicie i cokolwiek bym nie robił, wychodzi 255. Czy ktoś mógłby napisać mi w bascomie i umieścić na forum mały przykładzik testu tego EEPROMU?
Weź ściągnij sobie polski help do BASCOM'a (jest na Elportalu) przetłumaczony przez Zbigniewa Gibka - tam znajdziesz to czego szukasz.
Inna sprawa, że w katalogu SAMPLES BASCOMA masz podane przykłady wykorzystania tej pamięci przez I2C (domyślnie C:\Program Files\MCS Electronics\BASCOM-AVR\SAMPLES\I2c\I2C.BAS)
Wystarczy trochę poszukać...
Pozdrawiam!
Marcin "Max" G.
Ps. Widzę, że miesz(k)asz niedaleko
Inna sprawa, że w katalogu SAMPLES BASCOMA masz podane przykłady wykorzystania tej pamięci przez I2C (domyślnie C:\Program Files\MCS Electronics\BASCOM-AVR\SAMPLES\I2c\I2C.BAS)
Wystarczy trochę poszukać...
Pozdrawiam!
Marcin "Max" G.
Ps. Widzę, że miesz(k)asz niedaleko
-
Jimi Hendrix
- -
- Posty: 12
- Rejestracja: 29 lip 2005, 18:33
- Lokalizacja: Poznań
-
Jimi Hendrix
- -
- Posty: 12
- Rejestracja: 29 lip 2005, 18:33
- Lokalizacja: Poznań
strona 11, tabela na górze strony: 0xA0 - zapis, 0xA1 - odczyt
tasza
-
Jimi Hendrix
- -
- Posty: 12
- Rejestracja: 29 lip 2005, 18:33
- Lokalizacja: Poznań
Łopatologicznie:
'--------------------------------------------------------------
' (c) 1999-2002 MCS Electronics
'--------------------------------------------------------------
' file: I2C.BAS
' demo: I2CSEND and I2CRECEIVE
'--------------------------------------------------------------
Declare Sub Write_eeprom(byval Adres As Byte , Byval Value As Byte)
Declare Sub Read_eeprom(byval Adres As Byte , Value As Byte)
Const Addressw = 174 'slave write address - CO TU MAM WPISAĆ?
Const Addressr = 175 'slave read address - A TU?
Dim B1 As Byte , Adres As Byte , Value As Byte 'dim byte
Call Write_eeprom(1 , 3) 'write value of three to address 1 of EEPROM
Call Read_eeprom(1 , Value) : Print Value 'read it back
Call Read_eeprom(5 , Value) : Print Value 'again for address 5
'sample of writing a byte to EEPROM AT2404
Sub Write_eeprom(byval Adres As Byte , Byval Value As Byte)
I2cstart 'start condition
I2cwbyte Addressw 'slave address
I2cwbyte Adres 'asdress of EEPROM
I2cwbyte Value 'value to write
I2cstop 'stop condition
Waitms 10 'wait for 10 milliseconds
End Sub
'sample of reading a byte from EEPROM AT2404
Sub Read_eeprom(byval Adres As Byte , Value As Byte)
I2cstart 'generate start
I2cwbyte Addressw 'slave adsress
I2cwbyte Adres 'address of EEPROM
I2cstart 'repeated start
I2cwbyte Addressr 'slave address (read)
I2crbyte Value , Nack 'read byte
I2cstop 'generate stop
End Sub
'--------------------------------------------------------------
' (c) 1999-2002 MCS Electronics
'--------------------------------------------------------------
' file: I2C.BAS
' demo: I2CSEND and I2CRECEIVE
'--------------------------------------------------------------
Declare Sub Write_eeprom(byval Adres As Byte , Byval Value As Byte)
Declare Sub Read_eeprom(byval Adres As Byte , Value As Byte)
Const Addressw = 174 'slave write address - CO TU MAM WPISAĆ?
Const Addressr = 175 'slave read address - A TU?
Dim B1 As Byte , Adres As Byte , Value As Byte 'dim byte
Call Write_eeprom(1 , 3) 'write value of three to address 1 of EEPROM
Call Read_eeprom(1 , Value) : Print Value 'read it back
Call Read_eeprom(5 , Value) : Print Value 'again for address 5
'sample of writing a byte to EEPROM AT2404
Sub Write_eeprom(byval Adres As Byte , Byval Value As Byte)
I2cstart 'start condition
I2cwbyte Addressw 'slave address
I2cwbyte Adres 'asdress of EEPROM
I2cwbyte Value 'value to write
I2cstop 'stop condition
Waitms 10 'wait for 10 milliseconds
End Sub
'sample of reading a byte from EEPROM AT2404
Sub Read_eeprom(byval Adres As Byte , Value As Byte)
I2cstart 'generate start
I2cwbyte Addressw 'slave adsress
I2cwbyte Adres 'address of EEPROM
I2cstart 'repeated start
I2cwbyte Addressr 'slave address (read)
I2crbyte Value , Nack 'read byte
I2cstop 'generate stop
End Sub
-
Jimi Hendrix
- -
- Posty: 12
- Rejestracja: 29 lip 2005, 18:33
- Lokalizacja: Poznań