Shop OBEX P1 Docs P2 Docs Learn Events
Delay Loops — Parallax Forums

Delay Loops

kingnebkingneb Posts: 65
edited 2005-10-11 17:40 in General Discussion
I am running an SX28 or SX18 with the 4mhz internal oscilator.· How do you figure out the delay values for an X amount of seconds or microseconds?· Could u post a code sample and formula.· I am not running SX/B,·one of the most innefficient·compilers i've seen, assembler rules!···

thanks,
kingneb

Comments

  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-10-07 21:42
    Hi,

    please have a look at www.sxlist.com/techref/piclist/codegen/delay.htm for a delay code generator.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Kenneth KramerKenneth Kramer Posts: 11
    edited 2005-10-09 20:23
    You can find the "delay value" m in this loop:

    mov m,#?

    delay

    decsz m ; m + 1
    jmp delay ; 3*(m - 1)

    by the formula:

    x = (1/fclk)*(4m - 2) <==> m = (x*fclk + 2) / 4 .

    If you keep fclk in MHz you will have x in usec. Keep in mind that m >= 1.

    cheers,
    Kenneth
  • BeanBean Posts: 8,129
    edited 2005-10-10 02:16
    I don't agree that SX/B is an "innefficient" compiler...
    Not everyone is the master assembly language programmer, that you are. BTW did you figure out how to make a delay yet ?
    In SX/B I write "PAUSE x" where is x is the milliseconds to delay, or "PAUSEUS y" where y is the microseconds to delay.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012
    Product web site: www.sxvm.com
    Available now... SX-Video OSD module $59.95 www.sxvm.com

    "Save your money. Pay with cash."
    ·
  • John CoutureJohn Couture Posts: 370
    edited 2005-10-11 15:17
    I was wondering when one of the SX/B programmers was going to pipe up. Assembler may rule but SX/B yields a finished program in a reasonable amount of time. When was the last time you got an assembly program to work in one day (grin)? The SX/B compiler is actually pretty efficient and for routines that put too much code in, you can insert assembler directly after reading how the compiler does it. How kool is that!

    As to WHAT rules, you might want to heed the advice of someone that has a FINISHED product (grin) like Bean above. He has a product that has actually made it to market and presumably sells pretty well! Pretty impressive in my book!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-11 17:40
    FWIW, I posted my Serial Inkjet Code as a demonstration of what SX/B is capable of doing when handled with a bit of skill -- skills that all of us hold, no matter what language we use. I've become a very big fan of SX/B because it lets me get my work done quickly (all of the "smart" products we've created in the Parallax EFX group are programmed in SX/B) and I can learn assembly by looking at the output. In fact, during the testing phase I would often make adjustments to the SRC file and feed that information back to our compiler engineer for inclusion into the compiler. The nature of SX/B allows us to improve it quickly, hence the regular updates since its release (and yes, more are coming).

    I think it's fair to conclude that inefficiency is under the direct control of the programmer -- no matter what programming tool in his/her hands.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.