Dynamic variable loading?

Panda1989

Member
I'm out of non-volatile memory, but I still need to store more. Are there any other ways of dynamically loading data?

Example (psuedocode):

Code:
b1 = "Hello"
b2 = "Goodbye"

b3 = 1

Print b1 data

b3 = 2

Print b2 data

b3 = 1

Print b1 data again
Any ideas guys? It would be SO NICE for arrays to be supported in Picaxe. If there's no alternative I'll just have to use a long line of if/else statements.
 
Last edited:

Panda1989

Member
Nope, just found out table data is also stored in the EEPROM. Any methods you people know for dynamically retrieving data OUTSIDE the EEPROM?

Thanks.
 

demonicpicaxeguy

Senior Member
there are probably a few non implemented sfr's that could be used as storage areas

if you haven't used all the pins what about a 24lc256?
 

Panda1989

Member
there are probably a few non implemented sfr's that could be used as storage areas

if you haven't used all the pins what about a 24lc256?
Bit to late to order new hardware right now. As there's very little documentation on the scratchpad I'm having difficulty loading values from it. Here's a snippet of my code:

Code:
' Digit 1 Buffer
		if digit_1 = 8 then
			read ptr8, digit_1_buffer
		elseif digit_1 = 9 then
			read ptr9, digit_1_buffer
		else
			ptr = digit_1	
			digit_1_buffer = @ptr
		endif
			
		' Digit 2 Buffer
		if digit_2 = 8 then
			read ptr8, digit_2_buffer
		elseif digit_2 = 9 then
			read ptr9, digit_2_buffer
		else
			ptr = digit_2	
			digit_2_buffer = @ptr
		endif
ptr8 and ptr9 are standard variables. Anything I'm doing wrong?

I've defined the variables like so:

Code:
ptr0 = %01111110
  ptr1 = %00110000
  ptr2 = %10110110
  ptr3 = %10011110
  ptr4 = %11001100
  ptr5 = %11011010
  ptr6 = %11111010
  ptr7 = %00001110
  symbol ptr8 = b16
  ptr8 = %11111110
  symbol ptr9 = b17
  ptr9 = %11011110
 
Last edited:

hippy

Ex-Staff (retired)
It's probably worth reading up on SFR (Peek/Poke), Data Eeprom(Eeprom/Read/Write), Tables (Table/ReadTable) and Scratchpad(Get/Put) or things will start to get confusing.

Of which, the ReadTable refers to reading the scratchpad in Manual 2 - PICAXE Commands; it doesn't, it reads the table.

One way to do your multiple strings would be ...

Code:
Symbol Text1 = $00
Symbol Text2 = $06

Eeprom Text1,( "Hello",0 )
Eeprom Text2,( "Goodbye",0 )

b1 = Text1 : Gosub Print
b1 = Text2 : Gosub Print
End

Print:
  Read b1, b0
  If b0 <> 0 Then
    SerTxd( b0 )
    b1 = b1+1
    Goto print
  End If
  Return
 

BCJKiwi

Senior Member
@Hippy

Does this mean the table is another independent memory area of 256 bytes in addition to the eeprom and scratchpad, or does it use program space?
Manual2 refers to the "scratchpad", and "embedded lookup table", and "within the program" for the readtable command, and to the "eeprom" for the table command - not too clear to me. My best guess is that this table will be created in ram and take up program memory space - can you confirm?

It seems that using @ptr, @ptrinc/dec is faster than read eeprom and you can also do more with them like the inc/dec compared to eeprom.

Where does the table construct fit into the scheme of things?

Just created a table starting at 0 in an existing program with a 30 char text string and the syntax checker says the program size grew by 30 bytes.
Created a second table the same but stating at 200 and it took another 30 bytes.
I guess this means it is as suspected - table is created in ram in the program memory space. Niether scratchpad nor eeprom are changed when the table is created.

In the simulator, the table creation is instantaneous like it is for the eeprom setup i.e. the lines are just jumped over, there is no progress step by step along the text string as there is for many other commands so presumably this could be quite fast and therefore could be used within the program to update the table contents from time to time if the table is not large enough for everything at once.
 

hippy

Ex-Staff (retired)
Ram (SFR), Scratchpad, Data Eeprom,and Table are all separate. Data Eeprom is additional to program space ( shared on the smaller PICAXE's ), Table is part of Program Memory and works like additional Data Eeprom but it cannot be written to during program execution.
 

BCJKiwi

Senior Member
OK,
Thanks for the clarification - perhaps the manual wizards could tweak the description of the table command to remove references to scratchpad. While they are at it, perhaps a new topic called, say 'EEPROM Memory', could be added at the top of Manual2 right after Directives to cover Eeprom (Data) and Table decriptions as these appear to be a special case as they are both described in a similar manner and are not 'instructions' but program download 'commands'.

Thanks
 
Top