Help with reading memory

MikePembo

New Member
Hi,
I am currently doing a project that requires a 14M PICAXE chip to store a 62000 and below number in the epprom memory. (So when it is turned off the number is still stored in the memory.) My idea was that I could use all of the 255 memory location to store it. Here I am trying to read it and it doesn't work:confused:. See my code here:
(It is the bit in between the FOR and NEXT commands)
(the final result should end up in w6)

Code:
write 0, 1
''Read eeprom data (address)
read 0, b12

if b12 = 0 then
	w5 = 3
	w6 = 1
else
	for b9 = 0 to 255 step 1
		b8 = 0
		read b9,b8
		w6 = w6 + b8
	next
endif 
b12 = 0
Any help would be greatly appreciated!
Thanks,
Mike
 

Andrew Cowan

Senior Member
Hi Mike

I'm not following. You can store and read word variables into EEPROM using:

write location, WORD w1
read location, WORD w1

Remember that on the 14M the code uses up EEPROM space, so you'll never have all 255 locations.

Available space = 255 minus program length

A

Edit: Welcome to the forum!
 
Last edited:

lanternfish

Senior Member
Hi,
I am currently doing a project that requires a 14M PICAXE chip to store a 62000 and below number in the epprom memory.
As 62000 is less than 65535 then this can be stored as a word value (Andrew Cowan above).

So why would you want to use up all the eeprom space:confused: You will only have a bit left after your program is loaded!
 

MikePembo

New Member
I tried storing as a word value but it failed when I simulated. Could you show me an example of storing and reading the large number in EEPROM?
 

BCJKiwi

Senior Member
Code:
#picaxe 08M

for w0 = 1 to 62000
write 25, word w0
read 25, word w1
sertxd (#w1,"  ")
next w0
 

Andrew Cowan

Senior Member
Remember you have around 1,000,000 writes per EEPROM space before it starts acting oddly. So watch out if using BCJKiwi's code on an actual PICAXE, as it will only work around 20 times.

A
 

hippy

Ex-Staff (retired)
Also, whenever using a "READ <adr>,<var>" or "WRITE <adr>,<var/num>" it is recommened to also use an "EEPROM <adr>,(...)" command. This allows the value the Eeprom is initialised to to be specified and also reserves space for the data. The later prevents unintended corruption of programs where code and data is shared ( PICAXE-08, 08M, 14M, 18M, 20M ).

When storing word values in Eeprom it is necessary to use EEPROM commands for both bytes of that word ...

#Picaxe 08M
#Terminal 4800

Eeprom 25,( 0, 0 )

For w0 = 1 To 62000
Write 25, Word w0
Read 25, Word w1
SerTxd ( #w1, " " )
Next
 
Top