BasicMicro - Forums

www.basicmicro.com
It is currently Sat Feb 04, 2012 7:02 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to read and write external eeprom
PostPosted: Wed Aug 18, 2010 5:32 am 
Offline
Citizen

Joined: Thu Jul 15, 2010 5:07 am
Posts: 6
Hi,

I´m very new with atom micros.
I have basic atom 24 with external 24lc02 eeprom

basic writing and reading from eeprom is working ok

writing like :
i2cout p2, p3, %10100000, [0, 1]
i2cout p2, p3, %10100000, [1, 0]
i2cout p2, p3, %10100000, [2, 0]
i2cout p2, p3, %10100000, [3, 2]
i2cout p2, p3, %10100000, [4, 5]
i2cout p2, p3, %10100000, [5, 6]

reading like:

databyte = 0
address = 0
pause 100
for address = 0 to 5
i2cout p2, p3, %10100000, [address]
i2cin p2,p3, %10100000, [databyte]
next

My problem is that i don´t know how to read the memory
from many locations and form one variable from it.
I mean how to read for example memory locations (0-5) (100256)
and form one variable from them.

Also other way around. If i have variable what is for example
testnumber ="100256" how to write that to external eeprom to memory locations 0-5
one decimal per location.
I guess it has something to do with the arrays,but i don´t know how.


I´m sorry English isn´t my first language. It is quite difficult to explain what i mean.
I hope you understand my problem.

Could someone help, please.


Top
 Profile  
 
 Post subject: Re: How to read and write external eeprom
PostPosted: Wed Aug 18, 2010 6:23 am 
Offline
Citizen

Joined: Thu Jul 15, 2010 5:07 am
Posts: 6
poikkis wrote:
Hi,

I´m very new with atom micros.
I have basic atom 24 with external 24lc02 eeprom

basic writing and reading from eeprom is working ok

writing like :
i2cout p2, p3, %10100000, [0, 1]
i2cout p2, p3, %10100000, [1, 0]
i2cout p2, p3, %10100000, [2, 0]
i2cout p2, p3, %10100000, [3, 2]
i2cout p2, p3, %10100000, [4, 5]
i2cout p2, p3, %10100000, [5, 6]

reading like:

databyte = 0
address = 0
pause 100
for address = 0 to 5
i2cout p2, p3, %10100000, [address]
i2cin p2,p3, %10100000, [databyte]
next

My problem is that i don´t know how to read the memory
from many locations and form one variable from it.
I mean how to read for example memory locations (0-5) (100256)
and form one variable from them.

Also other way around. If i have variable what is for example
testnumber ="100256" how to write that to external eeprom to memory locations 0-5
one decimal per location.
I guess it has something to do with the arrays,but i don´t know how.


I´m sorry English isn´t my first language. It is quite difficult to explain what i mean.
I hope you understand my problem.

Could someone help, please.



öööh ...where is an edit button. ??
anyway little correction mikro is atom pro 24 not atom 24


Top
 Profile  
 
 Post subject: Re: How to read and write external eeprom
PostPosted: Wed Aug 18, 2010 8:40 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 784
Location: Temecula, CA
I would recommend you store the numbers as bytes, not characters. If you do that you only have to read back 4 bytes to get a long variable value.

Code:
temp var long
temp2 var long

temp = 12345678
temp2 = 0

i2cout p2, p3, %10100000, [0, temp.byte3,temp.byte2,temp.byte1,temp.byte0]

i2cout p2, p3, %10100000, [0] ;point to address 0 again
i2cin p2, p3, %10100000, [temp2.byte3,temp2.byte2,temp2.byte1.temp2.byte0]

_________________
Nathan Scherdin
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: How to read and write external eeprom
PostPosted: Wed Aug 18, 2010 9:14 am 
Offline
Citizen

Joined: Thu Jul 15, 2010 5:07 am
Posts: 6
Acidtech wrote:
I would recommend you store the numbers as bytes, not characters. If you do that you only have to read back 4 bytes to get a long variable value.

Code:
temp var long
temp2 var long

temp = 12345678
temp2 = 0

i2cout p2, p3, %10100000, [0, temp.byte3,temp.byte2,temp.byte1,temp.byte0]

i2cout p2, p3, %10100000, [0] ;point to address 0 again
i2cin p2, p3, %10100000, [temp2.byte3,temp2.byte2,temp2.byte1,temp2.byte0]




Working like charm
Thank you. !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO