Stack Length 2

Warning message

The Propeller Object Exchange system is decommissioned and replaced with a GitHub repository to house the same existing and future Propeller objects. As of 12/5/2019, this site is read-only. You can continue to browse and download objects from here for a limited time; however, please begin using the Parallax Propeller repository for future reference.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Request group membership
By: created: 2015-03-31 | updated: 2015-03-31

(2) 033015 ggysbers, modified "PUB GetLength(...)" so that the method will no longer initially clear the terminal
window while each line now ends with a "NL," New Line. Useful in testing multiple process
flow paths of a cog's work order.

Desc formatted properly in SPIN code.

Eg. +------------------------------------+
|Parallax Serial Terminal - (COMx) |
+------------------------------------+
| |
+------------------------------------+
|Stack Usage: 8 |
|Stack Usage: 9 |
|Stack Usage: 9 |
|Stack Usage: 13 |
|Stack Usage: 14 |
|Stack Usage: 14 |
|Stack Usage: 15 |
| |
+------------------------------------+

One's top level SPIN code may look similar to the following:

VAR
long TestStack[32] 'a stack of longs used by delay routine

OBJ
Stk : "Stack Length 2" 'Include Stack Length Object

PUB public_method_name

Stk.Init(@TestStack, 32) 'Initialize reserved Stack space (utilized below)

cognew(Toggle(16, 3_000_000, 10), @TestStack)
waitcnt(clkfreq * 6 + cnt) 'Pause 6 seconds
Stk.GetLength(30, 9600) 'Transmit results serially out P30 at 9600 baud

cognew(Toggle(2, 19_000_000, 11), @TestStack)
waitcnt(clkfreq * 10 + cnt) 'Wait ample time for max stack usage, 10 seconds
Stk.GetLength(30, 9600) 'Transmit results serially out P30 at 9600 baud

cognew(Toggle(81, 2_000_000, 500), @TestStack)
waitcnt(clkfreq * 10 + cnt) 'Wait ample time for max stack usage
Stk.GetLength(30, 9600) 'Transmit results serially out P30 at 9600 baud

PRI Toggle(x, y, z)
...

Original File Upload
AttachmentSize
Binary Data Stack Length 2.spin24.47 KB