View previous topic :: View next topic |
Author |
Message |
P_Santos
Joined: 07 Jul 2011 Posts: 114
|
Posted: Wed Sep 23, 2020 6:59 pm Post subject: Write and Read Dword variable to and from 24c64 Eeprom |
|
|
Hello,
I need to write on eeprom 24c64 a Dword variable, so 4 bytes
How can i write the Dword and Read it from the eeprom
To read a byte i use like this
address = &H432
Call E_read_ee(address , Tmp)
Thanks for any help
Best regards
P_Santos
(BASCOM-AVR version : 2.0.8.2 , Latest : 2.0.8.3 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Sep 23, 2020 9:11 pm Post subject: Re: Write and Read Dword variable to and from 24c64 Eeprom |
|
|
P_Santos wrote: | E_read_ee(address , Tmp) |
In case E_read_ee() is the only function you have, then use it or write one that fits better.
The 24C64 supports three read operations, current, random and sequential.
E_read_ee() equals a random read, while a sequential read would be more efficient.
If efficiency is not your primary goal, then call E_read_ee() four times and increase each time the address.
After each call of E_read_ee() store the byte into the appropriate byte of an array overlaid to the dword, like this:
Code: | Dim DW_var As DWord
Dim DWOvrl(4) As Byte At DW_var Overlay
'...
Call E_read_ee(address , Tmp)
DWOvrl(indx) = Tmp
Incr(address) : Incr(indx)
' next one
|
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Sep 24, 2020 9:41 am Post subject: |
|
|
have a look at the i2c samples. then tweak the code so it will read 4 bytes instead of 1.
i2cread / i2cwrite can do this very simple.
you should first check the data sheet of the chip to have an idea how this i2c chip works.
then read the i2c topic in the help to get a good idea about i2c fundamentals.
making an application glued together from postings is not a real good idea IMO. _________________ Mark |
|
Back to top |
|
|
P_Santos
Joined: 07 Jul 2011 Posts: 114
|
Posted: Thu Sep 24, 2020 10:04 am Post subject: |
|
|
Hello,
Thank's to both
MWS, the overlay is what I search
for, I will try that way
Best regards
P_Santos |
|
Back to top |
|
|
|