Speed of commands


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557

    Default Speed of commands

    I used a PIC12F1501 to try a little experiment. I wanted to see how much faster LATx.y = z works than HIGH PORTx.y. So here's the premise; 4 MHz OSC, LOOOOONNNGG DO/LOOP, and an LED that tells me which version I'm looking at. Here is the short version:

    DO
    HIGH LED
    FOR w0 = 1 to 10000
    HIGH PORTA.2
    LOW PORTA.2
    HIGH PORTA.2
    LOW PORTA.2
    (about 32 times)
    NEXT w0
    LOW LED
    FOR w0 = 1 to 10000.
    LATA.2 = 1
    LAT.2 = 0
    (another 32 times)
    NEXT w0
    LOOP

    I found commanding the LAT register to be about 3 times faster than using the HIGH/LOW commands. Just wanted to share.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Speed of commands

    HIGH and LOW commands first set the corresponding pin(s) to be output; then change the state of the pin to 1 or 0.

    Therefore, it produces a few more lines of code behind; and it takes longer time.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Speed of commands

    Yes you should be doing porta.2 = 1 once tris is setup once at the beginning.
    That would hopefully translate to a single set bit instruction.

Similar Threads

  1. SPI Commands Operating Speed
    By gunayburak in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th December 2016, 01:56
  2. Pic Speed / Instruction Speed etc
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th July 2012, 21:19
  3. Replies: 0
    Last Post: - 7th August 2008, 10:02
  4. commands that change A to D?
    By droptail in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th November 2006, 18:29
  5. At commands
    By jam547 in forum GSM
    Replies: 3
    Last Post: - 1st April 2006, 16:52

Members who have read this thread : 1

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