Shop OBEX P1 Docs P2 Docs Learn Events
about waitcnt — Parallax Forums

about waitcnt

caskazcaskaz Posts: 957
edited 2009-08-16 00:25 in Propeller 1
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)

Comments

  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-08-15 12:54
    The "+ cnt" is telling the Prop to count it using the crystal. Without it it will use the internal timing tool which is not as acurrite as the crystal.

    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)



  • BradCBradC Posts: 2,601
    edited 2009-08-15 13:10
    microcontrolled said...
    The "+ cnt" is telling the Prop to count it using the crystal. Without it it will use the internal timing tool which is not as acurrite as the crystal.

    I think that this the correct answer, but I am not an expert.

    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?
  • localrogerlocalroger Posts: 3,452
    edited 2009-08-15 14:18
    BradC is right, I recently did some tests of similar nature and this is right at the boundary of Spin's speed. 1,600 clocks at 80 MHz is 20 microseconds; I found that it took a Spin repeat/!dira[noparse]/noparse loop about 12 microseconds to loop. The time to interpret the waitcnt statement is probably putting it over 20.
  • caskazcaskaz Posts: 957
    edited 2009-08-16 00:25
    I understand.
    Thank you very much.
Sign In or Register to comment.