Delay question


Closed Thread
Results 1 to 22 of 22

Thread: Delay question

Hybrid View

  1. #1
    kata's Avatar
    kata Guest

    Default Delay question

    I don't find any specific answer to this question : Is it possible to have delay (for a specific protocol maybe) less than 1mS (say 335 uS) or I have to use ASM code ? Thank you for your time !

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Try the PAUSEUS command.

    Here are the details as listed in the manual - http://www.melabs.com/resources/pbpmanual/ - (which should of been the first place to look)

    PAUSEUS

    PAUSEUS Period

    Pause the program for Period microseconds. Period is 16-bits, so delays can be up to 65,535 microseconds. Unlike the other delay functions (NAP and SLEEP), PAUSEUS doesn't put the microcontroller into low power mode. Thus, PAUSEUS consumes more power but is also much more accurate. It has the same accuracy as the system clock.

    Because PAUSEUS takes a minimum number of cycles to operate, depending on the frequency of the oscillator, delays of less than a minimum number of microseconds are not possible using PAUSEUS. To obtain shorter delays, use an assembly language routine in an ASM..ENDASM construct.

    OSC Minimum delay
    3 (3.58) 20us
    4 24us
    8 12us
    10 8us
    12 7us
    16 5us
    20 3us
    25* 2us
    32* 2us
    33* 2us
    40** 2us

    * PIC17Cxxx and PIC18Cxxx only.
    ** PIC18Cxxx only.

    PAUSEUS assumes an oscillator frequency of 4MHz. If an oscillator other that 4MHz is used, PBP must be told using a DEFINE OSC command. See the section on speed for more information.

    PAUSEUS 1000 ' Delay for 1 millisecond

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c
    Try the PAUSEUS command.

    Here are the details as listed in the manual - http://www.melabs.com/resources/pbpmanual/ - (which should of been the first place to look)

    That's amazing isn't it? You find the wierdest information in the oddest places. Especially if the information (the PBP book) came with the program package (bought directly from MeLabs).
    JDG

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Come on Skimask
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jan 2007
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Can someone please explain me how to use assembly to make shorter delay than pauseus can make ?

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    The shortest possible delay is achieved by using the assembler command NOP (short for No OPeration):
    Code:
    @NOP       'Delay for OSC/4
    The NOP instruction takes 1uS at 4Mhz and 250nS at 20Mhz etc. If you want longer delay add more NOP instructions or build a loop, but then it's probably easier to use PauseUs anyway.

    /Henrik Olsson.

Similar Threads

  1. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. RF Transmitter
    By et_Fong in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th October 2005, 16:34
  4. Memory Space of the PIC16F84...
    By Tear in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st July 2005, 19:55
  5. Problem with saving to EEPROM...
    By Tear in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st July 2005, 00:10

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts