Shop OBEX P1 Docs P2 Docs Learn Events
Doing Wait Right? - Page 2 — Parallax Forums

Doing Wait Right?

2»

Comments

  • tonyp12tonyp12 Posts: 1,951
    edited 2011-07-19 14:08
    Pause: You stop the code right here and now for short specific time, you don't care what time is was when you get here.

    Interval: You want to wait so the counter is at 1000,2000, 3000,4000........ etc
    and that the code that you run after the wait takes 100-500 ticks etc does not adds up to the total interval time.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2011-07-19 23:47
    1 nanosecond = 1.0
  • TubularTubular Posts: 4,726
    edited 2011-07-20 00:45
    1 nanosecond = 1.0
  • Heater.Heater. Posts: 21,230
    edited 2011-07-20 07:27
    Hmm... amongst all the confusion over the use of waitcnt I have to agree with one thing that Kirk Fraser said:
    waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt) what a bunch of gibberish!

    This would certainly would not have passed through the software quality control guys on various military and avionic projects I have been involved with.

    Not that it is gibberish exactly but having such "magic" numbers littering the code was not allowed. There would at least be defines or constants provided to help out with documentation and provide a single place to change such values.

    Worse still is that this code is somewhat brittle.
    Those magic numbers depend on what code the compiler produces, perhaps OK if there is only ever one, from Parallax, but perhaps bigspin or such would generate a bit longer bytecode sequences and break that line of code.
    Then it depends on the execution time of the bytecode interpreter. Again OK if there is only ever one but breaks if one uses a little slower interpreter.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2011-07-20 07:50
    Tubular wrote: »
    With your 12 bit PWM you are unlikely to achieve the <4 CLK on-times due to the time it takes to toggle a pin (Unless you invoke multiple cogs or a counter). ie your PWM might be able to achieve 0, 4, 5, 6... 4095, but perhaps not 2 or 3.

    What FET are you using? It may do nothing when given a 10ns pulse anyhow.

    I was using an IRL530 on a BS2, now Phil recommends an IRF3708 to match the Prop's 3.3V.

    I'm somewnat concerned with the results using a voltage level output to drive the FET input pin. So I'm hoping the PWM signal will work better. If I have to avoid values 1-3 out of 0-4095 it's probably not a big deal, but it's good to know, thanks.

    Hopefully it'll be getting at least a 20KHz pulse, not only 10ns.
  • User NameUser Name Posts: 1,451
    edited 2011-07-20 08:10
    Is your understanding of waitcnt complete?

    This is shocking almost to the point of sacrilege. Nevertheless, I giggled when I read it.
Sign In or Register to comment.