Shop OBEX P1 Docs P2 Docs Learn Events
Stack Space for Full Duplex Serial Driver v1.2 object — Parallax Forums

Stack Space for Full Duplex Serial Driver v1.2 object

JoeFLJoeFL Posts: 10
edited 2013-01-17 11:41 in Propeller 1
I'm lost for a little comprehension about Chip Gracey and Jeff Martin's Full Duplex Serial Driver object
and how much stack space is required and where is addr for this stack space?

PUB start(rxpin, txpin, mode, baudrate) : okay


'' Start serial driver - starts a cog
'' returns false if no cog available
''
'' mode bit 0 = invert rx
'' mode bit 1 = invert tx
'' mode bit 2 = open-drain/source tx
'' mode bit 3 = ignore tx echo on rx


stop
longfill(@rx_head, 0, 4)
longmove(@rx_pin, @rxpin, 3)
bit_ticks := clkfreq / baudrate
buffer_ptr := @rx_buffer
okay := cog := cognew(@entry, @rx_head) + 1 <
what addr is @ rx_head ?

If this is started from Cog_0 , then the stack addr is [0]
If this is started from say Cog_4 , and cognew starts in Cog_5 , then what is the addr @ rx_head ?

Approx how much stack space does this object use?

Thanks

Joe

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-17 11:41
    FullDuplexSerial, like a lot of I/O drivers, consists of two parts: 1) an assembly language (PASM) I/O driver that runs in a cog and 2) a Spin interface to the PASM I/O driver. The PASM I/O driver, like all PASM code, doesn't use a stack. The 2nd parameter to COGNEW is a parameter passed to the PASM program, in this case it's the address of a table of pointers and other information passed from the .start routine to the PASM I/O driver. If you look at the VAR declarations at the beginning of the object, you'll see rx_head followed by a number of other variables.

    The Spin portion of the object runs in the cog that calls it and it uses the stack used by that cog. You have to remember that objects and cogs are different like apples and donuts. An object can use several cogs to do its work or it can use no cogs at all other than the one that calls its public methods. An object is just a way to encapsulate a function ... to make a sort of library package to do something for you. A cog is a separate computer. You can have a program that consists of just one object (the main one) yet uses all the cogs of the Propeller.
Sign In or Register to comment.