about waitcnt
caskaz
Posts: 957
Hi.
I have question.
Spin below operate pulse-out(H=21use L=21usec).
But replacing [noparse][[/noparse]waitcnt(T += 1_700)] to [noparse][[/noparse]waitcnt(T += 1_600)] , there is not pulse-out.
Replacing [noparse][[/noparse]waitcnt(T += 1_700)] to [noparse][[/noparse]waitcnt(1_600 + cnt)] , pulse-out . (pulse-time not accurate)
I can't undaerstand why.
Please teach me reason.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB test|T
dira[noparse][[/noparse]0]~~
T := cnt
repeat
!outa[noparse][[/noparse]0]
waitcnt(T += 1_700)
I have question.
Spin below operate pulse-out(H=21use L=21usec).
But replacing [noparse][[/noparse]waitcnt(T += 1_700)] to [noparse][[/noparse]waitcnt(T += 1_600)] , there is not pulse-out.
Replacing [noparse][[/noparse]waitcnt(T += 1_700)] to [noparse][[/noparse]waitcnt(1_600 + cnt)] , pulse-out . (pulse-time not accurate)
I can't undaerstand why.
Please teach me reason.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
PUB test|T
dira[noparse][[/noparse]0]~~
T := cnt
repeat
!outa[noparse][[/noparse]0]
waitcnt(T += 1_700)
Comments
I think that this the correct answer, but I am not an expert.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Computers are microcontrolled.
Robots are microcontrolled.
I am microcontrolled.
But you·can·call me micro.
If it's not Parallax then don't even bother.
I have changed my avatar so that I will no longer be confused with others who use generic avatars (and I'm more of a Prop head then a BS2 nut, anyway)
I think you will find SPIN is just too slow do to 1600 cycles in that loop. If 1700 works and 1600 does not then it's just now quick enough with what you want it to do. SPIN tends to be relatively slow when compared against PASM. 1700 is about 425 PASM instructions. You are inverting outa[noparse][[/noparse] 0 ] in that loop, which is not terribly fast.
If you need it to cycle faster you'll need to move to PASM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
Thank you very much.