What are the maximum limits of peeking/poking address in SLOTS ??

OLDmarty

Senior Member
Hi All,

After reading info on using Peek/Poke commands to access extra memory locations (or assigning more variables beyond the B0 to B55 in 28X2/40X2 picaxes).
My understanding is:
The 28X2 & 40X2 devices have: 256 bytes of user RAM (+1024 more in scratchpad)

That means 256+1024 = 1280 bytes we can access via peek/poke commands.
(Obviously the first 56 bytes are equally accessable via b0 to b55 (or w0 to w27) variables too).

So, if a SLOT in a 40X2 is 4096 bytes, Is it possible to still access the bytes above the 1280 byte range?

My question is, if a slot has 4096 bytes available for 'code', then why not access almost all 4096 bytes for a huge storage of variables or whatever?
(Subract a handful of bytes to configure the slot to switch back to other slots for the main program (run 0, run 1 etc)
As long as we confirm the code in each slot is xx bytes long (let's say upto 96 bytes of housekeeping to go back to Slot 0, that leaves 4000 bytes available, per slot.

So, in affect, Slot 0 could be the main program, and slot 1,2 & 3 could potentially be 3x 4k (12k total) of byte storage?

Am i totally off the rails here? or am i correct with the maths?

Thanks in advance.
 

techElder

Well-known member
The short answer to your question is that all of that "memory" beyond 1280 bytes is not RAM.

However, depending on your coding, you can store date within program code. You might have other uses for your RAM or EEPROM.

I've used this technique for loading data for displaying on an LED display. You can use common RAM variables that get loaded within a subroutine by branching statements.

That's one way to use those extra "bytes" in SLOTS.
 

Aries

New Member
You can (sort of) use the program memory in the slots as additional read-only memory (not writable by the program) by using LOOKUPs.
There are also potentially 256 bytes of TABLE (again, read-only).

This is an extract from one of my 28X2 programs: slot 0 is the main program, slot 2 handles formatting and display on a 16x2 or 20x4 LCD display. This is part of slot 2 - the formatting instructions for each field are provided in a set of 6 bytes. In my case, the data is used within the same slot - it makes the interfacing back and forth between slots much simpler.
Code:
LoadDisplayBuffer:
    ptr = DisplayBuffer
    b17 = b13                                            ' save for branching
    b18 = 0                                                ' step through display definition
    for b0 = 0 to 15                            ' 12 lines of 6 bytes + terminator
        for b1 = 0 to 5                            ' collect 6 at a time
            select case b17
        case 0                                        ' Local date/time/temperature
                lookup b18,(_
                    Address_SP,  MyTimeData_DayOfWeek,      RangeDOW, %00011100,        0,                    %00010001,    _
                    Address_SP,  MyTimeData_Day,            0,        %00010010,        0,                    %00001000,    _
                    Address_SP,  MyTimeData_Month,          0,        %00010010,        0,                    %00100000,    _
                    Address_SP,  MyTimeData_Year,           0,        %00010010,        0,                    %00100000,    _
                    Address_SP,  MyTimeData_Hours,          0,        %00010010,        0,                    %01000000,    _
                    Address_SP,  MyTimeData_Minutes,        0,        %00010010,        0,                    %01011000,    _
                    Address_SP,  MyTimeData_Seconds,        0,        %00010010,        0,                    %01011000,    _
                    Address_RAM, CurrentOutsideTemperature, 0,        %01110110,        0,                    %01001010,    _
                    Address_TBL, S_Degrees,                 0,        %00001011,        0,                    %01000000,_
                    $FF,0),w1

            case 1                                        ' Thermostat data
                lookup b18,(_
                    Address_TBL, S_Thermostat,              0,        %00100011,        0,                    %00000001,_
                    Address_RAM, CurrentThermostat,         Range18,  %00001101,        1,                    %00000000,_
                    Address_RAM, CurrentThermostatID,       0,        %00010010,        0,                    %00111000,_
                    Address_TBL, S_Type,                    0,        %00100011,        0,                    %00001000,_
                    Address_RAM, CurrentThermostatType,     Range05,  %00001101,        2,                    %00110000,_
                    Address_TBL, S_Temperature,             0,        %00100011,        0,                    %01000000,_
                    Address_RAM, CurrentThermostatTemperature,0,      %01100101,        0,                    %01110010,_
                    Address_RAM, CurrentThermostatStatus,   Range01,  %00011100,        0,                    %01001000,    _
                    $FF,0),w1
            else                                            ' empty display
                lookup b18,(_
                    $FF,0),w1
            endselect
' ... process w1 as required
' ...
            b18 = b18 + 1
        next b1
    next b0
 

inglewoodpete

Senior Member
@OLDmarty, Do you have i2c or SPI pins free on your 40X2? You can utilise these to access an external RAM chip. If you are using the i2c or SPI bus, you can add a RAM chip (or EEPROM) to these busses.
 

OLDmarty

Senior Member
@OLDmarty, Do you have i2c or SPI pins free on your 40X2? You can utilise these to access an external RAM chip. If you are using the i2c or SPI bus, you can add a RAM chip (or EEPROM) to these busses.
Hi IP,

Yeh, external Ram/EEprom is fine, but i was just trying to clarify the amount available in the slots, just another learning adventure.
 
Last edited:

hippy

Senior Member
i was just trying to clarify the amount availabale in the slots, just another learning adventure.
And the answer, as stated, is "none". The only writeable areas are RAM ( which includes the named variables ) and Scratchpad, both of which are per PICAXE rather than per slot.

There are the special variables (s_wX) plus a few locations accessible via PEEKSFR and POKESFR which can be used for additional writeable storage but they would not generally be used as such.

Anything which requires more than 1280 bytes of RAM probably isn't that suitable for a PICAXE.

The most likely case of wanting large amounts of RAM I can think of would be to hold a bitmap display in memory for a graphical LCD display, so that bitmap can be updated with it then being churned out to the display.
 

OLDmarty

Senior Member
And the answer, as stated, is "none". The only writeable areas are RAM ( which includes the named variables ) and Scratchpad, both of which are per PICAXE rather than per slot.
Ahhh, ok, so there are only 256 General bytes (includes 56 variables) and 1024 scratchpad bytes shared across all 4 slots in a 40X2?
I misread the info and thought it was 256 & 1024bytes 'per slot'.

This means there is 4096 bytes 'per slot' for code (with the option to deduct 256 bytes of table memory if needed)

I kept thinking the 4096 size INCLUDED the 256 bytes of general ram AND the 1024 scratchpad bytes, which would leave a measly 2816 bytes for code, which clearly isn't true ;-)

The picaxe doc(s) seriously needs a whole page dedicated to a decent Picaxe Memory MAP as a point of reference for all of us.


The most likely case of wanting large amounts of RAM I can think of would be to hold a bitmap display in memory for a graphical LCD display, so that bitmap can be updated with it then being churned out to the display.
Well, yes, or even a brief sound-effect sample to play out ;-)
 

OLDmarty

Senior Member
OK, i'm working on a memory map to clarify things for myself.

Some clarifications please:
For 28X2/40X2 chips, Is TABLE memory (256 bytes) located at the 0 to 255 locations in the shared program code area?
Assuming i used up all 256 bytes in a large TABLE, is the program code officially then located at 256 to 4095 (3840 bytes remaining for code) ???

For M2 chips, The TABLE memory (512 bytes) looks to be located on it's own, no longer being shared with program code space.
IF the General (variable) data is at 0 to 255, is TABLE memory located at 256 to 767?, and then program code space is from 768 to 2047?

For 08M2 chips, It seems GENERAL (variable) memory (256 bytes) is located at the 0 to 255 locations in the shared program code area?.
Assuming i used up all 256 bytes with all the variables and memory upto 255, is the program code officially then located at 256 to 2047 (1792 bytes remaining for code) ???
 

hippy

Senior Member
IF the General (variable) data is at 0 to 255, is TABLE memory located at 256 to 767?, and then program code space is from 768 to 2047?
No. As far as the PICAXE model is concerned; RAM runs from 0 up to 255, Eeprom runs from 0 up to 255, Table runs from 0 up to 255, Program runs from 0 up to 4095.

In the cases where things are shared, Program/Eeprom on the 08M2, Program/Table on the X2, everything still runs from 0 upwards, but as one increases the top limit of one the other may be reduced, hence the way some things are shown as triangular in the Post #10 image.

For the X2, Program memory starts at 0 at the top of the image, Table memory starts at 0 at the bottom of the image. As one uses more of either the top of the other can reduce.

Hence, if no Table is used, Program can fill 0 to 4095. If Table location 0 is used, Program can fill 0 to 4094. If Table location 1 is used, Program can fill 0 to 4093. All the way to when Table location 255 is used when Program can fill 0 to 3839.

Conversely, so long as the Program only uses up to 3839, all Table locations 0 to 255 are available for use. When Program uses 3840, Table locations reduce, become 0 to 254. All the way up to Program using 4095 when no Table will be available for use.

It's like a video shelf, with DVD's filling it from the left, Bluerays filling it from the right. The left most and right most numbered as zero. Once the shelf is full you can only add a DVD by removing a Blueray, or vice versa.

For Program/Table there is space for 4096 DVD's and/or Bluerays, with a cap of a maximum 256 Bluerays.
 

Aries

New Member
Assuming i used up all 256 bytes in a large TABLE, is the program code officially then located at 256 to 4095 (3840 bytes remaining for code) ???
You don't have to have one large TABLE - you can equally well have a lot of small TABLEs - although the effect is identical.
And just one other small point - the 14M2 and 20M2 have 512 bytes of RAM as well as 512 bytes of TABLE.
 
Top