Overwrite Eeprom?

George Sephton

Senior Member
What do I do to clear or overwrite the Eeprom. Im using the data between 80 and 100 but I want to be able to overwrite that, is that possible because ive looked around the internet and the picaxe manual and the programming editor doesn't let me it says it already being used.

thanks,
George S.
 

westaust55

Moderator
Overwrite EEPROM

with EEPROM, when you download a program, the PE will automatically clear data EEPROM locations if there are no EEPROM statements.
Have a look at the EEPROM statement in the very latest (Rev 6.6) of PICAXE manual page 42.

If you store data in EEPROM during exection of a program, that will stay there and you would need to write $00 to each location you want to clear.

What is the purpose in clearing the locations?
Excessive writing to the EEPROM does reduce the life of the EEPROM which have around 100,000 write operation life.
 
Last edited:

George Sephton

Senior Member
Ah I see.
Well here's my code (basically):
Code:
data 70,("Top Line")
    data 87,("Bottom Line")
    gosub WriteToTop
    gosub WriteToBottom
WriteToTop:
    outbyte = $80
    gosub SendCmdByte
    
    for b2 = 70 to 86
        read b2,outbyte
        gosub SendDataByte
    next b2
    return

WriteToBottom:
    outbyte = $C0
    gosub SendCmdByte
    
    for b3 = 87 to 127
        read b3,outbyte
        gosub SendDataByte
    next b3
    return
so I need to add a w0 = "top line" then include in the sub WritetoTop a read w0 but when I change it to: (ive added the symbol)
Code:
toptext = "Top Line"
    bottomtext = "Bottom Line"
    gosub WriteToTop
    gosub WriteToBottom
    goto Main
it always highlights this line: toptext = "Top Line" and says syntax error.
I don't know why thats why Ive been using eeprom.
 

westaust55

Moderator
The PICAXE cannot handle text strings. so these lines are invalid:
toptext = "Top Line"
bottomtext = "Bottom Line"​

You can use the SYMBOL directive to create constants. One example:

Code:
SYMBOL TopLine = 70
SYMBOL BotLine = 87


data Topline,("Top Line")
data Botline,("Bottom Line")
Not exactly sure what you are trying to achieve.
If you are trying to avoid fixed values in the writetotop and writetobottom routines then you need so set up some values in variables.
 
Last edited:

George Sephton

Senior Member
but how do I create a text string without using eeprom?

EDIT: sorry just tried what you said, works great thanks! :D
 
Last edited:

George Sephton

Senior Member
Wait a minute that brings me back to where I started with the eeprom. I need to have a variable with string in it, then use the sub to write it to the LCD then change the variabe and write something else later, the lcd will be constantly updating so i need to be constantly changing that variable.
 

westaust55

Moderator
other than EEPROM, another method is along these lines where the string is embedded in the program:

Code:
          FOR pointer = 0 TO 18
          LOOKUP pointer,("* Hi PICAXE Forum*  "),value
          GOSUB ValueToLCD
        NEXT
 

George Sephton

Senior Member
That works but is it really necssary? everytime I do a loop like that it uses 40 bytes and there's only limited time that can happen.
Thats why I wanted to use a sub. To put the string into a variable and run a sub to do the loop so it only has to be defined once. It uses so much less memory it just sucks that there's no way of storing a string of text into a variable that can then be called.
What would be helpful is if you could do functions like most programming languages: function("TEXT HERE") and then read that text in the function.
 

Dippy

Moderator
As Westy says, PICAXE cannot handle strings.
Besides, all micros only store each individual charcter byte as a block of bytes, it's just that PICAXE is a bit limited where it stores it.

Is Table and ReadTable any use?
You don't say which PICAXE you are using...... and I've hung my crystal ball on the Christmas tree.
 

hippy

Ex-Staff (retired)
The PICAXE is quite constrained down at the low pin count end and text takes up a lot of space which has to be put somewhere and string manipulation can require a fair amount of Firmware code as well. They simply do not have the oomph to do all the things a PC can.

There are ways to store multiple text strings just once ( in Eeprom ) and then you use a pointer / index into Eeprom via READ to determine which string characters to display. Those strings can be copied into SFR and accessed with PEEK/POKE but there's limited capacity in SFR and it doesn't really gain much over using READ.

Squeezing things into the smaller PICAXE's can get tricky and is an art form in design and implementation. Optimising data storage means inceasing code size and it can be a never-ending battle to get it balanced right. I find the effort sometimes just isn't worth it and it's easier to use an 18X or above which gives a lot more memory capacity.
 

Dippy

Moderator
Sorry, I've just realised how badly phrased my previous post was.

Well, if you can store most of your preset messages in EEPROM that would be handy.

Maybe you can use 'Poke' to poke away a block of ASCII chars?

If you can common-ise some of the words/phrases then it can save space.
i.e. make up 'string' building-blocks in EEPROM.

In any event, you will have to read them back and plonk them to LCD one at a time in a loop as you know.
Tedious , but possible with a little patience and thought.

Think about how you can construct subroutines to do as much as possible.

You must remember that, whatever PIC language you use, a byte is a byte and a single ASCII char is a byte it has to be stored somewhere on the PIC. (Please don't mention compression).
 

hippy

Ex-Staff (retired)
Please don't mention compression

Only in passing ... Any compression of data requires an increase in code to handle it, which is that battle on the smaller PICAXE's.
 
Top