Shop OBEX P1 Docs P2 Docs Learn Events
Is it possible to use floating point decimals in a WAITCNT — Parallax Forums

Is it possible to use floating point decimals in a WAITCNT

idbruceidbruce Posts: 6,197
edited 2011-01-07 07:34 in Propeller 1
I realize it probably isn't possible, but thought I would ask.

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-01-06 16:41
    A float is just a measurement of magnitude so yes but you would have to convert the float to an integer. 1.5 can be 1.5*10 = 15.0.

    How long do you want to wait?
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-01-06 16:42
    idbruce wrote: »
    I realize it probably isn't possible, but thought I would ask.

    Since the WAITCNT waits on the system counter and the counter works in integers, I would say it can't be done.

    EDIT: well, Mike G is correct - you can always convert your decimal to integer and then use that, but you can't use decimal directly.
  • idbruceidbruce Posts: 6,197
    edited 2011-01-06 16:43
    So in reality it has to be a whole number. Thanks.

    Bruce
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-06 17:17
    Bruce: Yes, the waitcnt is counting actual clocks (which is usually 12.5ns = 80MHz) so it has to be an integer.
  • ericballericball Posts: 774
    edited 2011-01-07 03:48
    The system counter is a 32 bit register which increases by 1 every clock cycle. WAITCNT specifies a value which the cog will halt until the system counter reaches. Therefore "wait until system counter = 1234.5678" doesn't make a heck of a lot of sense. Wait for 1.5 seconds makes more sense, in which case you would (float) multiply the value by CLKFREQ and use the (integer) result added to the current value of CNT.
  • Mike GMike G Posts: 2,702
    edited 2011-01-07 07:32
    Nicely said ericball. That's the point I was trying to make.
  • idbruceidbruce Posts: 6,197
    edited 2011-01-07 07:34
    Thanks To All Who Responded

    I solved the problem that I was having, but I definitely appreciate your input.

    Thanks Again
    Bruce
Sign In or Register to comment.