Delay question


Closed Thread
Results 1 to 22 of 22

Thread: Delay question

Hybrid View

  1. #1
    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.

  2. #2
    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 ?

  3. #3
    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.

  4. #4
    Join Date
    Jan 2007
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    thank you, as i understand 1us is minimum limit for 4mhz crystal

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


    Did you find this post helpful? Yes | No

    Default

    Therian,
    Yes, that is correct. With a 4Mhz X-tal one intruction cylce is 1uS and since the NOP command takes one cycle to execute the delay will be 1uS.

    /Henrik Olsson.

  6. #6
    Join Date
    Jan 2007
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    just curious, is 250nS enough to generate radio frequency directly from pic without any rf modules, it sound like cheap radio link

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


    Did you find this post helpful? Yes | No

    Default

    Therian,
    Well, let's see:
    Code:
    Start:
      PortB.1 = 1     'Set pin high        
    @ NOP             'Wait....Two NOP's are neede if we want 50% dutycycle
    @ NOP             'since the GOTO takes two instruction cylcles.
      PortB.1 = 0     'Set pin low
    Goto Start        'Do it again. The GOTO takes the same time as two NOP's
    This, I think, will generate a pulsetrain with 50% duty cycle. The frequency would be ~833kHz. Not much of a radio frequency.... besides that, you can't do anything else in the code without slowing it down more...much more.

    /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