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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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)
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)
No bug. Wait only takes a byte parameter 0-255. Use 10us or such as needed.
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.
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
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.