18F series performance not so good?


Closed Thread
Results 1 to 17 of 17

Hybrid View

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

    Default 18F series performance not so good?

    Hello to all survivors of too many redirects....

    I finally got PIC18F45K80 running, and settings are correct - run multiple PAUSE statements and measured times with scope. But I'm not impressed with performance at all.

    The simple code

    SOME:
    HIGH PORTB.1
    LOW PORTB.1
    GOTO SOME:

    On the 16F series, outputs frequency that of 1/4 of OSC speed- say osc is 8mhz, output will be 2mhz and so on (and contrary some recomendations, replacing HIGH/LOW with LATB=X or TRISB=X does not improve the speed).

    Now I have 18F45K80 running at 64mhz.

    Code:
    #config
    CONFIG RETEN = OFF	
    CONFIG INTOSCSEL = HIGH
    CONFIG SOSCSEL = DIG
    CONFIG XINST = ON	    ;Enabled
    CONFIG FOSC = INTIO1
    CONFIG PLLCFG = OFF
    CONFIG FCMEN = OFF	    ;Disabled
    CONFIG PWRTEN = OFF	    ;Disabled
    CONFIG BOREN = OFF	    ;Disabled in hardware, SBOREN disabled
    CONFIG WDTEN = OFF	    ;WDT disabled in hardware; SWDTEN bit disabled
    CONFIG CANMX = PORTB
    CONFIG MCLRE = OFF
    
    
    #endconfig
    
    
    OSCTUNE.6 = 1 ; Enable 4x PLL
    OSCCON = %01110000
    ANCON1=0 'DISABLE ADC D3-D2-D1-D0-
    ancon0=0
    TRISC=%00000000 'set PORTC as output all
    TRISD=%00000000 'set PORTD as output all
    TRISB=%00000000 'set PORTB as output all
    TRISA=%00000000 'set PORTA 2 as input, others as output
    TRISE=%0000000  'set PORTE as output all
    define OSC 64
     
    GKO:
    HIGH PORTc.7
    'PAUSEus 1
    LOW PORTc.7
    'PAUSEus 1
    GOTO GKO
    But output frequency is about 2.5mhz, but it should be at least 16mhz.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default Re: 18F series performance not so good?

    I do not have that chip and cannot test it.

    But 16MHz cannot be output as the main clock is 64MHz and divided by 4 gives system clock of 16MHz. So each MCU tick is 62.5ns. I really do not know how many tick will take your program to execute, maybe 5 or 6? Worst case might be around 380ns or 2.6MHz.

    Ioannis

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: 18F series performance not so good?

    On the 16F series, outputs frequency that of 1/4 of OSC speed- say osc is 8mhz, output will be 2mhz and so on (and contrary some recomendations, replacing HIGH/LOW with LATB=X or TRISB=X does not improve the speed).
    Not in my world a pic @8mhz [12,16 or 18] would get nowhere near that


    GKO:
    HIGH PORTc.7
    LOW PORTc.7
    GOTO GKO


    TRANSLATES TO 5 LOOP instructions no matter whether its pic16 or pic18


    GKO
    BCF PORTC 7 1CYC
    BCF PORTC+12H 7 1CYC
    BSF PORTC 7 1CYC
    BCF PORTC+12H 7 1CYC
    BRA GKO 2CYC
    AS IOANNIS states around 380ns or 2.66MHz @64MHZ




    GKO:
    LATC.7 = 0
    LATC.7 = 1
    GOTO GKO


    TRANSLATES TO 3 LOOP instructions no matter whether its pic16 or pic18
    GKO
    BCF LATC 7 1CYC
    BSF LATC 7 1CYC
    BRA GKO 2CYC
    around 250ns or 4MHz @64MHZ



    DITTO FOR


    LATC.7 = 0
    GKO:
    TRISC.7 = 0
    TRISC.7 = 1
    GOTO GKO


    TRANSLATES TO 3 LOOP instructions no matter whether its pic16 or pic18
    GKO
    BCF TRISC 7 1CYC
    BSF TRISC 7 1CYC
    BRA GKO 2CYC
    around 250ns or 4MHz @64MHZ
    Warning I'm not a teacher

  4. #4
    Join Date
    Aug 2011
    Posts
    453


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: 18F series performance not so good?

    I agree with richard. There's no way your numbers are correct, and directly using LAT vs HIGH/LOW should ALWAYS get you almost 2x the performance.

    One thing in your setup... never set XINST=ON as it changes the way some instructions work.
    Code:
    CONFIG XINST = ON	<<<<<<<<<<<

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


    Did you find this post helpful? Yes | No

    Default Re: 18F series performance not so good?

    Well I posted all that several years ago, with the scope screenshots. Later I'll try to find that topic and bring it up.

    So issue is, why 18F is so slow, and is there a way to fix it?

  6. #6
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: 18F series performance not so good?

    It's not so slow... you're seeing what it should be.
    The 16F isn't any faster. Since the max clock is 32MHz, it'll be half the speed.

    If you want the 18F to be faster use LAT as Richard showed.

Similar Threads

  1. Replies: 7
    Last Post: - 21st September 2014, 01:59
  2. Moving on to 18F series.
    By Tina10 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 4th September 2012, 05:50
  3. 18F series challenges
    By Charlie in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd July 2011, 15:32
  4. 18f series chip locked up
    By glkosec in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th August 2009, 07:27
  5. OT - Firefox browser - faster performance
    By malc-c in forum Off Topic
    Replies: 2
    Last Post: - 14th August 2006, 10:33

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