12F683, 12LF1840 - Port ON/OFF speeds are different!


Closed Thread
Results 1 to 18 of 18

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: 12F683, 12LF1840 - Port ON/OFF speeds are different!

    No, there's not way to shorten the execution time (in instruction cycles that is) of a GOTO. What you can do is to "lengthen" the time of the other instructions.
    Code:
    Head:
    PortA.2 = 1
    @ NOP   ' Two nops to compensate for the GOTO
    @ NOP
    PortA.2 = 0
    GOTO Head
    Obviously this will also change the frequency.

    /Henrik.

  2. #2
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default Re: 12F683, 12LF1840 - Port ON/OFF speeds are different!

    How about if you toggle pin in loop?

    Code:
    HEAD:
    TOGGLE PORTA.2
    GOTO HEAD

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


    Did you find this post helpful? Yes | No

    Default Re: 12F683, 12LF1840 - Port ON/OFF speeds are different!

    I don't want to "lengthen" time, because it significantly lowers the frequency, from about 1mhz to 200khz, which is bad. I've found a partial workaround - I've inserted

    Code:
    PORTA.2=1
    PORTA.2=0
    PORTA.4=1
    PORTA.4=0
    16 times, so now having about 90% duty cycle, which is ok.

    But, is there a way to fix this otherwise?

    Try 18 series PIC, or 24 series?

  4. #4
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: 12F683, 12LF1840 - Port ON/OFF speeds are different!

    Have you considered doing this in assembly??
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  5. #5
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: 12F683, 12LF1840 - Port ON/OFF speeds are different!

    It's same thing in ASM.
    ASM
    tavukaASM:
    BSF PORTA,2
    BCF PORTAM2
    BSF PORTA,4
    BCF PORTA,4
    GOTO tavukaASM
    ENDASM

    That is ASM code equivalent of his PBP code.
    Still same situation....
    Last edited by pedja089; - 3rd February 2015 at 21:09.

  6. #6
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default Re: 12F683, 12LF1840 - Port ON/OFF speeds are different!

    Would it be easier to do this with PWM module? With 32MHz you can reach 4MHz output frequency and accurate duty cycle.
    I think these PIC's have just one PWM module. If that is not enough, then select other which have more PWM outputs.
    At least, trials can be run with your current PIC's.
    Last edited by Gusse; - 3rd February 2015 at 21:50.

  7. #7
    Join Date
    Feb 2013
    Posts
    1,153


    Did you find this post helpful? Yes | No

    Default Re: 12F683, 12LF1840 - Port ON/OFF speeds are different!

    Well, I asked that before...

    I use 2 channels as you can see from scope, and I need to have adjustable dead time between outputs, to avoid short circuit. Is it possible to synchronise 2 PWM generators in that way?

Similar Threads

  1. Pulsin ir receiver and osc speeds
    By jimseng in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 24th March 2012, 20:12
  2. 18F2520 - problem configuring fuse for port B as digital port.
    By hwhisperer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th October 2010, 12:41
  3. LCD R/S works on Port A but not Port B
    By TDonBass in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th February 2009, 13:41
  4. Dual clock speeds on a PIC
    By BrianT in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th January 2008, 02:34
  5. Duplicating port input to port output
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th April 2004, 22:43

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