Understand 14M2 memory.

iz3kxw

New Member
Hi, may be you heard many times this question, but unfortunally for me is not completely clear.
As the manual say, our pic have: Memory program 2048 bytes
Ram 521 bytes (28 bytes variable and 483 bytes for storage)
Eeprom 256 bytes (not volatile)
Because the label of the Ram and the Eeprom is the same, es. b0, b1, b2, b3 etc. which is the way to choose the one i want?
As i understood to choose Eeprom byte the only way is using Write and than Read, to choose Ram byte using all the other commands.
Is correct what i wrote?

many thanks for your help.

Andrea.
 

AllyCat

Senior Member
Hi Andrea,

Yes, the EEPROM has 256 bytes which can (only) be acessed by the READ and WRITE commands.

The RAM has 512 bytes (0 - 511) which can be accessed by the equivalent PEEK and POKE commands.

However, there are many other ways to access some of the RAM bytes:

The first 28 bytes (0 - 27) can be directly accessed by the b0 - b27 variables and also in pairs as w0 - w13.

The first 4 bytes can also be accessed at the bit level, i.e. bit0 - bit31.

Finally, all the RAM bytes can be accessed via the byte pointer (bptr) indirection operator (@bptr). It's basically the same as PEEK and POKE, but the advanatge of bptr is that it can be used in expressions exactly like the bx variables and also with optional increment or decrement (e.g. @bptrinc = @bptr + @bptr ; "shift byte left and advance pointer").

Cheers, Alan.
 

westaust55

Moderator
Additionally the M2 parts when using the Programming Editor V6 has access to two (2) program memory slots each of 2048 bytes.
This is a new capability mentioned in the PE V6 notes but still awaiting the updated PICAXE manual 2.

Should you in future use X2 parts then you also have scratchpad memory accessed with PUT and GET commands and the ptr indirect pointer. (No "b" on the front like the M2 "bptr" general RAM pointer).
 

iz3kxw

New Member
Alan, westaust55, many thanks for your explanation. Now all sound clear for me. One more question: when I write or read the eeprom, I must to do it byte by byte or can I do it with the entire word? (es. b0, b1, b2, b3 or w0, w1 , w2 etc.)
Thanks for your help.
Andrea.
 

westaust55

Moderator
One more question: when I write or read the eeprom, I must to do it byte by byte or can I do it with the entire word? (es. b0, b1, b2, b3 or w0, w1 , w2 etc.)
.
The Syntax for the EEPROM reading and writing are in the format:
WRITE location,data ,data, WORD wordvariable...

Accordingly, you can write and read data between EEPROM and a work variable but must preface the word variables with the “WORD” parameter

eg WRITE b5, WORD w4


Note that this cannot be applied to the EEPROM or DATA command used to pre-load the EEPROM memory at the time of program download. With these commands only byte values can be included in the code.
 

iz3kxw

New Member
Ok westaust55 all clear.
Now I can start with my project sure to use the memory correctly.
thanks a lot.
Andrea.
 
Top