PhilHornby
Senior Member
I've recently been porting some code from a Picaxe 08M2 to a Picaxe 14M2, because I'd run out of memory (it's a WebServer implementation).
The intention was to make use of #SLOT 1 on the 14M2 to effectively double the amount of memory available (and get some more back because EEPROM doesn't overlap Program Space on the 14M2 like it does on the 08M2).
Then I remembered the TABLE command...
There's not a massive amount of documentation on it, so I did some experimenting. The Webserver is part of a larger project and gets its data from a nearby Picaxe 20X2, so I did some playing around with TABLE on that as well.
This is what I found:-
[highlight]Picaxe 20X2[/highlight]
[highlight]Picaxe 14M2[/highlight]
I can't see a whole lot of advantages in using TABLE data on the 20X2 - but the sudden discovery of an extra 1KByte of data on the 14M2 is a revelation. The fact that it survives an Editor "CLEAR" operation may be a good or a bad thing - I've not decided yet.
I wrote a little test program (attached) that demonstrates some of these effects (on the 14M2).
Warning: The demo program prints the contents of the TABLE data to the Serial Terminal. As observed in this thread PE6 Serial Terminal can consume VAST amounts of system resources. You may find you need to restart it frequently, and/or clear its buffer. It's much better to use something like Putty, but then you have to remember to close it before programming
The intention was to make use of #SLOT 1 on the 14M2 to effectively double the amount of memory available (and get some more back because EEPROM doesn't overlap Program Space on the 14M2 like it does on the 08M2).
Then I remembered the TABLE command...
There's not a massive amount of documentation on it, so I did some experimenting. The Webserver is part of a larger project and gets its data from a nearby Picaxe 20X2, so I did some playing around with TABLE on that as well.
This is what I found:-
[highlight]Picaxe 20X2[/highlight]
- Using TABLE() data reduces the amount of code space available.
- If no TABLE() statement is present in the source file, any existing TABLE data is CLEARED from the microcontroller (unless the #No_table Directive is present). I.e. the same approach as EEPROM() data.
[highlight]Picaxe 14M2[/highlight]
- TABLE() data does NOT reduce the amount of code space available.
- If no TABLE() statement is present, any existing data in the microcontroller (if any) is RETAINED unchanged. (The Editor "CLEAR" function does NOT delete it either.)
- TABLE() data, if present in the source file, is ALWAYS loaded into the microcontroller - the #No_table directive is NOT supported.
- Each Slot has its OWN 512 bytes of TABLE data - so there is [highlight]1KByte in total[/highlight].
I can't see a whole lot of advantages in using TABLE data on the 20X2 - but the sudden discovery of an extra 1KByte of data on the 14M2 is a revelation. The fact that it survives an Editor "CLEAR" operation may be a good or a bad thing - I've not decided yet.
I wrote a little test program (attached) that demonstrates some of these effects (on the 14M2).
Code:
[COLOR=navy]#picaxe [/COLOR][COLOR=black]14m2[/COLOR]
[COLOR=navy]#no_data [/COLOR][COLOR=green];not testing EEPROM. [/COLOR]
[COLOR=navy]#terminal 4800 [/COLOR][COLOR=green];Serial Terminal doesn't like all this data - may need restarting regularly :-(
[/COLOR]
[COLOR=navy]#slot 0
[/COLOR]
[COLOR=green]; Demonstration of 14M2 TABLE data
;Instructions:-
; 1. Ensure Statement above is set to #Slot 0, Uncomment Table 1 and Program Picaxe. Table 1 will be printed.
; 2. Set Statement above to #Slot 1, Comment out Table 1 again, Uncomment Table 2 and Program Picaxe. Table 2 will be printed.
; (NOTE: Slot 1 runs immediately after it has been programmed. Picaxe now contains Table 1 in Slot 0 and Table 2 in Slot 1.
;
; 3. Set Statement above to #Slot 0, Comment out Table 2 as well and Program Picaxe. Table 1 will be printed again.
; 4. Set Statement above to #Slot 1, and Program Picaxe. Table 2 will be printed.
;
; 5. Set Statement above to #Slot 0, uncomment 'RUN 1 and Program Picaxe. Both Table 1 + 2 will be printed.
;
; 6.Change Statement above to #Slot 1 and change 'RUN 1' to 'RUN 0' and Program Picaxe - both tables will printed ad infinitum.
; (Slot 0 prints Table 1 and 'chains' Slot 1. Slot 1 prints Table 2 and 'chains' Slot 0
;
; 7. Finally - CLEAR Picaxe with Editor. Comment out both tables. Reload program to both slots. Data is still there!
#rem
;
; Table 1 512 bytes.
;
TABLE ("Now is the winter of our discontent, made glorious summer by this son of York. ")
TABLE ("Now is the winter of our discontent, made glorious summer by this son of York. ")
TABLE ("Now is the winter of our discontent, made glorious summer by this son of York. ")
TABLE ("Now is the winter of our discontent, made glorious summer by this son of York. ")
TABLE ("Now is the winter of our discontent, made glorious summer by this son of York. ")
TABLE ("Now is the winter of our discontent, made glorious summer by this son of York. ")
Table ("1234567890123456789012345678901")
#endrem
#rem
;
; Table 2 another 512 bytes.
;
TABLE ("There should be laughter after pain, there should be sunshine after rain, These ")
TABLE ("things have always been the same. Why worry now? Dire Straits, doncha know :-) ")
TABLE ("There should be laughter after pain, there should be sunshine after rain, These ")
TABLE ("things have always been the same. Why worry now? Dire Straits, doncha know :-) ")
TABLE ("There should be laughter after pain, there should be sunshine after rain, These ")
TABLE ("things have always been the same. Why worry now? Dire Straits, doncha know :-) ")
Table ("1234567890123456789012345678901")
#endrem
;if W0 <> 512 then ;if we've been run before (tends to kill Serial Terminal!)
[/COLOR][COLOR=blue]pause [/COLOR][COLOR=navy]2000 [/COLOR][COLOR=green];wait for terminal (to start/recover!)
;endif
[/COLOR][COLOR=blue]For [/COLOR][COLOR=purple]W0 [/COLOR][COLOR=darkcyan]= [/COLOR][COLOR=navy]0 [/COLOR][COLOR=blue]To [/COLOR][COLOR=navy]511
[/COLOR][COLOR=blue]Readtable [/COLOR][COLOR=purple]W0[/COLOR][COLOR=black],[/COLOR][COLOR=purple]b2 [/COLOR][COLOR=green];get the byte from TABLE
[/COLOR][COLOR=blue]Sertxd ([/COLOR][COLOR=purple]b2[/COLOR][COLOR=blue]) [/COLOR][COLOR=green];and send it out of the serial port
[/COLOR][COLOR=blue]Next[/COLOR]
[COLOR=green]; RUN 0 ;chain the 'other' slot.[/COLOR]
Attachments
-
2.7 KB Views: 7
Last edited: