Picbasic pro speed issues?


Closed Thread
Results 1 to 8 of 8

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Picbasic pro speed issues?

    Hi,
    As have been said, and to add a bit: HIGH/LOW are commands which not only set the pin HIGH and LOW, it also makes the pin an output even if it already IS an output. Your code, compiled for a 12F683 (yes, it's different when compiled for other targets) results in the following ASM output:
    Code:
    _Cycle
       bsf     GPIO,   000h
       bsf     STATUS, RP0
       bcf     ((GPIO) + 80h), 000h
       bcf     STATUS, RP0
       bcf     GPIO,   000h
       bsf     STATUS, RP0
       bcf     ((GPIO) + 80h), 000h
       bcf     STATUS, RP0
       goto    _Cycle
    All instructions takes one cycle except the GOTO which takes two and if you count the number of cycles you'll get 10. With the PIC running at 4MHz each instruction cycles takes 1us so the loop takes 10us to complete which matches your 100kHz measurement exactly.

    Now, if you'd do something like this instead:
    Code:
    TRISIO.0 = 0
    
    Cycle:
      GPIO.0 = 1
      GPIO.0 = 0
    Goto Cycle
    The resulting ASM code looks like this:
    Code:
    .
       bsf     STATUS, RP0
       bcf     TRISIO, 000h
       bcf     STATUS, RP0
    
    _Cycle
       bsf     GPIO,   000h
       bcf     GPIO,   000h
       goto    _Cycle
    Now the actual loop is only 4 cycles instead of 10 so you'd get 250kHz instead of 100kHz when operating the PIC at 4MHz - quite a difference.

    /Henrik.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: Picbasic pro speed issues?

    Thanks!

    Perfect explanation.

    Maybe there are results of how much each command on average "consumes".

    And regarding the other PICs, will be loss the same as with that one, or it will be less or more?

  3. #3
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: Picbasic pro speed issues?

    I've compared pic12 and 16 series on above operation. when clock is the same, speed is also same. how 18xxx will perform, any ideas?

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Picbasic pro speed issues?

    I can't see an 18F doing more than 1 instruction per cycle. I would think that's when multiple core CPUs come in, but that's another architecture.

    I have seen 18Fs run at 64MHz though.

    Robert

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Picbasic pro speed issues?

    Quote Originally Posted by HenrikOlsson View Post
    ...
    Now the actual loop is only 4 cycles instead of 10 so you'd get 250kHz instead of 100kHz when operating the PIC at 4MHz - quite a difference.

    /Henrik.
    At 64MHz, you'd get 16 times faster, 4MHz.

    Robert

Similar Threads

  1. conversion from picbasic to picbasic pro
    By winjohan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st November 2011, 18:00
  2. PICBasic Pro vs Proton PICBasic
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd November 2006, 16:11
  3. Who have Picbasic Pro?.
    By tsupuntu in forum mel PIC BASIC
    Replies: 3
    Last Post: - 9th August 2006, 20:45
  4. Get picbasic pro
    By Nicksterjack in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th March 2005, 12:14
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 21:19

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