Google came up with an interesting piece of code.
I did some tests and it seems to do the trick.
If called using "@ wait 0" it delays 1uS,
if called using "@ wait 1" it delays about 2,5uS,
if called using "@ wait 2" it delays about 3uS.
So, the delay is not the problem anymore.Code:asm shortwait macro del ; used by main wait macro if (del>3) && (del<8) call del7+(7-(del)) endif if del <4 if del>=2 goto $+1 endif if ((del) & 1) == 1 nop endif endif endm endasm asm wait macro del ; if (del)<0 error 'negative delay' ; endif if (del)>=8 movlw ((del)-8) /4 call delay shortwait ((del-8) % 4) else shortwait (del) endif endm delay addlw 0xff skpnc goto delay return del7 goto del5 ; 7 cycle delay del6 goto del4 ; 6 cycle delay del5 nop ; 5 cycle delay del4 return ; 4 cycle delay ENDasm
However, when called from picbasic like :
The delay is about 33uS instead of 2. I understand that the delay would be longer, but 30uS extra ??Code:led1 var word led2 var word led1 = 2 led2 = 2 start: GPIO = %01 @ wait _led1 GPIO = %10 @ wait _led2 goto start
Can someone, please, point me in the right direction ?




Bookmarks