Menu

Is there a bug in WAIT

Help
2009-08-05
2013-05-30
  • David Stephenson

    Using the following code

    dim dly as word
    start:
    dly=10
    wait dly us
    dly=dly+1
    goto start

    the delay works fine EXCEPT when dly=256 (and multiple thereof)

     
    • Nobody/Anonymous

      Oops the start: and dly=10 are the wrong way round. The post should read:

      Using the following code

      dim dly as word
      dly=10
      start:
      wait dly us
      dly=dly+1
      goto start

      the delay works fine EXCEPT when dly=256 (and multiple thereof)

       
    • Nobody/Anonymous

      No bug.  Wait only takes a byte parameter 0-255.  Use 10us or such as needed.

       
    • David Stephenson

      If you look at the ASM for the us delay you will see that it is clearly designed to accept words as well as bytes.

      Delay_US
          incf    SysWaitTempUS_H, F
      DUS_START
          nop
          nop
          decfsz    SysWaitTempUS, F
          goto    DUS_START
          decfsz    SysWaitTempUS_H, F
          goto    DUS_START
          return

      as I said it works for delays longer than 255 us but there just seems to be some carry problem when the delay is 256, 512 etc.

       
    • David Stephenson

      Ok I've put it on my oscilloscope and I get the following
      wait 255 us gives a delay of about 250 us
      wait 256 us gives a delay of about 500 us
      wait 257 us gives a delay of about 250 us

      everything is ok up to the next carry and as might be expected wait 512 us gives a delay of about 770 us

       
    • Hugh Considine

      Hugh Considine - 2009-08-08

      Oops, that was a silly mistake! That bug should now be fixed, please try http://gcbasic.sourceforge.net/newfiles/update.zip or update-nochipdata.zip.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.