Shop OBEX P1 Docs P2 Docs Learn Events
Mike G- I give... help please? — Parallax Forums

Mike G- I give... help please?

RforbesRforbes Posts: 281
edited 2013-07-20 06:16 in Accessories
Mike (Or anyone else! :) )

Ok, I give here.... I'm trying to figure out why you're using the value 3932 in one of your methods in the old HTTPServ app.
PRI Pause(Duration)  
  waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt)
  return

I understand the syntax, math and the rest of this little method, but... why this particular 3932 value? It's gotta signify something, but I'm stumped on what it is.

Help me out here please?

Robert

Comments

  • msrobotsmsrobots Posts: 3,709
    edited 2013-07-19 18:39
    it is a constant found out by experiment to adjust for the amount of time the spin statements take to execute.

    Enjoy!

    Mike
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-19 18:44
    Rforbes wrote: »
    Mike (Or anyone else! :) )

    Ok, I give here.... I'm trying to figure out why you're using the value 3932 in one of your methods in the old HTTPServ app.
    PRI Pause(Duration)  
      waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt)
      return
    

    I understand the syntax, math and the rest of this little method, but... why this particular 3932 value? It's gotta signify something, but I'm stumped on what it is.

    Help me out here please?

    Robert

    I think I know this one. The 3932 value is the overhead of the call.

    With is value subtracted from the delay a call of "Pause(1)" will pause the program exactly one millisecond (give or take a few nanoseconds) if the 3932 correction hadn't been subtracted, the call would have been 3932 clock cycles longer than a millisecond.

    Edit: Or what Mike said.
  • RforbesRforbes Posts: 281
    edited 2013-07-20 06:16
    Hey guys,

    Got it. So the 3932 value would change depending on the *exact* structure of the method, because the command overhead would take a different amount of clock cycles. Appreciate ya's!
    Robert
Sign In or Register to comment.