Delay question


Results 1 to 22 of 22

Thread: Delay question

Threaded View

  1. #15
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Not to muddy the waters because it sounds like you have decided on another route, but for completeness ...

    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
    at 4 MHz, 3 instructions on and 3 instruction off = 6 instructions per cycle, therefore f=1000000/6=166666.667 Hz (twice that noted above)

    Interestingly enough the above code does 3 instructions on and 4 instructions off on 16F devices and 3 on 3 off on 18F (at least on an 18F877A and 18F452, respectively). To combat this on the 16F's, you could do something like this in ASM

    Code:
    ASM
    here
        bsf PORTB,1
        NOP
        NOP
        bcf PORTB, 1
        goto here
    ENDASM
    Good Luck
    Last edited by paul borgmeier; - 5th March 2007 at 21:02.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

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