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


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,124

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

    Hello.

    I'm building an push-pull converter driver using these chips. The code is as follows:

    Code:
    'PUSH PULL DRIVER
    
    ANSELA = %00000000  'TURN OFF ANALOG  
    TRISA=%00000000     'SET PORTS TO OUTPUT
    OSCCON = %11111111  'SET INTOSC TO 32MHZ
    
    
    tavuka:
    
    PORTA.2=1
    PORTA.2=0
    PORTA.4=1
    PORTA.4=0
    
    GOTO TAVUKA
    The problem is, that measured port OFF times are longer than ON times, as you can see on attached scope:

    Name:  hugedelay.jpg
Views: 1224
Size:  27.0 KB

    Any ideas how to fix this?

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,632


    Did you find this post helpful? Yes | No

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

    OSCCON = %11111111 'SET INTOSC TO 32MHZ
    looks wrong
    OSCCON = %11110000 'SET INTOSC TO 32MHZ would be more appropriate assuming int osc and pll

    porta.x = y on a 12f1840@32mhz is just asking for trouble use lata.x=y

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


    Did you find this post helpful? Yes | No

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

    Yes, config is wrong, but problem is same at ANY clock speed.

    Tried with LATA - no difference. ON time is about 220ns, OFF time is about 760ns. In terms of PWM, this means 50% duty, so another 50% is simply wasted.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

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

    As I see, this is caused by loop, which returns program to beginning.

    For example, I've tried to lengthen code by repeating commands 4 times without using loop, and 4 pulses are correct.

  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!

    I hope that you are kidding with us...
    Here is your code explained:
    tavuka:
    PORTA.2=1'<turn on PORTA.2, need 4 osc clock to do that, then next instruction
    PORTA.2=0'<turn off PORTA.2 need 4 osc clock to do that, then next instruction
    PORTA.4=1'<4 clock to do this, but it doesn't do anything with PORTA.2
    PORTA.4=0'<4 clock to do this, but it doesn't do anything with PORTA.2
    GOTO TAVUKA '<4 or 8 clocks(can remember) to do this, but it doesn't do anything with PORTA.2
    So when you count all clock, you have 4 osc clock long high state on PORTA,2, and 16 clock low state on PORTA.2.
    Similar situation is with PORTA.4...
    Program execute exactly what you are tell, Not what you want...

  6. #6
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

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

    Even if code is like this:

    Code:
    HEAD:
    PORTA.2=1
    PORTA.2=0
    GOTO HEAD
    the "goto" occupies much more time. Is there a way to shorten it?

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    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.

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

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

    the 1840 in ECCP half bridge mode looks to be fine too, no ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Pulsin ir receiver and osc speeds
    By jimseng in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 24th March 2012, 19: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, 11: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, 12:41
  4. Dual clock speeds on a PIC
    By BrianT in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th January 2008, 01:34
  5. Duplicating port input to port output
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th April 2004, 21: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