Shop OBEX P1 Docs P2 Docs Learn Events
Another bizarre question... — Parallax Forums

Another bizarre question...

SmittySmitty Posts: 9
edited 2005-02-12 02:28 in BASIC Stamp
This code...

MAIN:
   DEBUG "."
   'check for input
   SERIN    16, 240, 15, TIMEOUT, [noparse][[/noparse]WAIT("*"), STR cmdIn\2]

   'do some stuff
   GOTO AFTER_INPUT

TIMEOUT:
   'do some stuff

AFTER_INPUT:
   'do some stuff

   GOTO MAIN




Should run NO FASTER than 66 times per second with no input. There is a 15 ms timeout value... 1000ms / 15 ms = 66.6... and that doesn't even consider the time to execute all of the other instructions in the "Do some stuff" sections...

So when I let it run for 10 seconds, why does it print over 4000 dots in the console? I cut and pasted the output into notepad, saved it as a text file, and checked the file size in bytes... I tried various run times to get a better average... they all show that a dot is printed roughly every .0029 seconds.

How can this loop run in less than 3 ms per iteration when it should take 15 ms just to timeout?

(This could explain some funky timing issues with SERIN...)

Comments

  • MacGeek117MacGeek117 Posts: 747
    edited 2005-02-11 22:55
    Could you please post the whole program-you might get more help.
    bugg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I think I know what I'm doing...
  • SmittySmitty Posts: 9
    edited 2005-02-11 23:06
    Well, the only line that is of any importance is the SERIN line... here, I rewrote it with nothing else in it. This program exhibits the very same behavior with only one SERIN statement, one debug statement, and 2 gotos.

    I tested this particular program for 10 seconds... the loop ran in about 8 ms despite a 15 ms timeout. (My math was a little off before... its still way fast--2x what it should be--but not as bad as I indicated earlier).

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}
    
    cmdIn VAR Byte(2)
    
    MAIN:
      SERIN 16, 240, 15, NO_INPUT, [noparse][[/noparse]WAIT("*"), STR cmdIn\2]
      GOTO MAIN
    
    NO_INPUT:
      DEBUG "."
      GOTO MAIN
    
    
  • achilles03achilles03 Posts: 247
    edited 2005-02-12 02:28
    Ah, that's why... it's an SX. You should have stated that in your first post. The units for the timeout for the SX are .4ms, not 1ms.

    Dave
Sign In or Register to comment.