Shop OBEX P1 Docs P2 Docs Learn Events
TopObject memory and FDS StartUp question. — Parallax Forums

TopObject memory and FDS StartUp question.

CannibalRoboticsCannibalRobotics Posts: 535
edited 2011-07-22 17:04 in Propeller 1
How does one determine the 'stack' usage of the top object?
With other objects, there is a stack address and size that can be used.

If I want to start and stop FullDuplex serial to change the i/o pin numbers to communicate with multiple devices, how long should I wait to send data after calling the start. I'm thinking in SPIN terms it's pretty quick since it's a PASM object.

Thanks in advance-

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2011-07-22 14:05
    If I remember right starting a new cog takes around 100 microseconds. You could try to immediatly send a string after the serial.start-command. If the string has different chracaters it will be easy to see which characters are readedin properly on the receiverside.
    Anyway FullDuplexSerial uses a sendbuffer. This means if you want to send characters they get stored in the buffer. This storing is done by the SPIN-cog who calls the methods str, dec, bin etc. As long as you don't "overfill" the sendbuffer I guess you can start immediatly.

    keep the questions coming
    best regards

    Stefan
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-07-22 15:10
    Jim,

    When you say "TopObject" I think you really mean "cog 0". Each Spin cog requires it's own stack. The first cog that starts up will use the memory immediately after the VAR space for it's stack. This stack could extend all the way to the end of hub RAM, though most programs use less than 100 longs for their stack. In your other thread about Stack Posers I posted some code that measures cog zero's stack usage.
    pub WritePattern
      longfill(@result + 40, $F00DFEED, ($8000 - @result - 40) >> 2)
    
    pub StackUsed | ptr
      ptr := $7FFC
      repeat while long[ptr] == $F00DFEED
        ptr -= 4
      return ptr + 4 - WORD[10]
    
    WritePattern put's a known pattern in cog zero's stack area. StackUsed will return the number of bytes that have been used. WritePattern must be called from cog 0, but StackUsed could be called from another cog, which could continually montor cog zero's stack.

    As far as FDS. You can write to it immediately after you call the start routine. The data will queue up in the outbound buffer, and TX will wait if the buffer gets full.

    Dave
  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-22 17:00
    Your problem isn't so much in waiting after starting FDS before sending the first character, it's the question of when FDS is finished sending what's already in the buffer and then waiting for it to actually finish sending the last character so you can stop FDS and change to a different set of I/O pins. To do this, you have to add an additional routine to see when the transmit buffer is empty, then wait an amount of time equal to at least 10 bit times for the last character to be sent. I think there's a txcheck in the FDS routine used in DongleBasic (from the Object Exchange) that does what you want. You might have a look at that. I don't have access to any of my objects at this time.
  • kuronekokuroneko Posts: 3,623
    edited 2011-07-22 17:04
    In addition to what Mike said, have a look at the thread [thread=129809]FullDuplexSerial Object - Detecting when data has been sent[/thread] for previous discussions (and solutions).
Sign In or Register to comment.