PIC Math - the need for speed


Results 1 to 19 of 19

Threaded View

  1. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I determined it was 48 cycles by using this procedure ...

    instruction execution time
    http://www.picbasic.co.uk/forum/showthread.php?t=365

    I've double checked, and it's definately 48. Although my hardware is different, 18F452 @ 20Mhz, it shouldn't make that much difference.

    For your test routine I get these results:
    Code:
    Value = 20000
    Start:                     ' Cycles   uS@20mhz
        PORTD.0 = 1            '    1         .2
        Delay = Value /*$004D  '   48        9.6
        PORTD.0 = 0            '    1         .2
        PauseUs 700            ' 3501      700.2   
    Goto Start                 '    2         .4
                                 -----     -----
                  ' Loop Total   3553      710.6
    And, this I didn't expect. Here's the results from Ingvar's first example
    Code:
                                ' Cycles   uS@20mhz
    Dummy1 = OldPulseTime >> 2  '  31        6.2
    Delay = Dummy1 >> 2         '  31        6.2
    Delay = Delay + Dummy1      '   4         .8
                                 -----     -----
                  '      Total     66       13.2
    But, his second one looks pretty quick. As long as .3125 is close enough.
    Code:
                                ' Cycles   uS@20mhz
    Dummy1 = OldPulseTime >> 1  '   5        1.0
    Dummy1 = Dummy1 >> 1        '   3         .6
    Delay = Dummy1 >> 1         '   5        1.0
    Delay = Delay >> 1          '   3         .6
    Delay = Delay + Dummy1      '   4         .8
                                 -----     -----
                  '      Total     20        4.0
    Last edited by Darrel Taylor; - 10th October 2005 at 21:46.
    DT

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  3. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  4. My PIC can't do the math! Can yours?
    By sayzer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th May 2006, 07:28
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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