18f2550 oscillator problems


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2007
    Posts
    26

    Default 18f2550 oscillator problems

    Hi all,

    I am running an 18f2550 using internal oscillator. I have a timing problem that causes the program to run what I believe is 4 times slower than it should.

    I have the following fuses set in 18f255.inc in the PBP directory.

    __CONFIG _CONFIG1L, _PLLDIV_1_1L
    __CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H
    __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _PBADEN_OFF_3H
    __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L

    I have the following code running on chip.

    OSCCON=%01100000
    DEFINE OSC 4
    TRISA=%0000000
    ADCON1 = 7 ' A/D off, all digital
    high PORTA.5
    pause 1000
    low PORTA.5
    pause 1000
    high PORTA.5

    I am sure the LED on PORTA.5 is staying on for 4 seconds and then goes off for 4 seconds before finally coming back on. What am I doing wrong?

  2. #2
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Sorry, I should also have said I am using MPASM

  3. #3
    Join Date
    Sep 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Try to set de _PLLDIV_1_1L to _PLLDIV_5_1L. This is also the setting when I'm using USB on the 18F2550 with a 20MHz oscillator.

    Regards,
    Ronald.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i'll bet on
    Code:
            __CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    INTOSCIO ??? How about INTCKO instead.

    Try -- OSCCON=%01111100
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    INTCKO is not a valid fuse in my current MPASM version (5.11) for the 18F2550
    Code:
    ;----- CONFIG1H Options --------------------------------------------------
    _FOSC_XT_XT_1H       EQU  H'F0'    ; XT oscillator, XT used by USB
    _FOSC_XTPLL_XT_1H    EQU  H'F2'    ; XT oscillator, PLL enabled, XT used by USB
    _FOSC_ECIO_EC_1H     EQU  H'F4'    ; External clock, port function on RA6, EC used by USB
    _FOSC_EC_EC_1H       EQU  H'F5'    ; External clock, CLKOUT on RA6, EC used by USB
    _FOSC_ECPLLIO_EC_1H  EQU  H'F6'    ; External clock, PLL enabled, port function on RA6, EC used by USB
    _FOSC_ECPLL_EC_1H    EQU  H'F7'    ; External clock, PLL enabled, CLKOUT on RA6, EC used by USB
    _FOSC_INTOSCIO_EC_1H EQU  H'F8'    ; Internal oscillator, port function on RA6, EC used by USB
    _FOSC_INTOSC_EC_1H   EQU  H'F9'    ; Internal oscillator, CLKOUT on RA6, EC used by USB
    _FOSC_INTOSC_XT_1H   EQU  H'FA'    ; Internal oscillator, XT used by USB
    _FOSC_INTOSC_HS_1H   EQU  H'FB'    ; Internal oscillator, HS used by USB
    _FOSC_HS_1H          EQU  H'FC'    ; HS oscillator, HS used by USB
    _FOSC_HSPLL_HS_1H    EQU  H'FE'    ; HS oscillator, PLL enabled, HS used by USB

    and the OSCCON was right in the first post.

    Sorry mackrackit
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    INTCKO is not a valid fuse in my current MPASM version (5.11) for the 18F2550
    Code:
    ;----- CONFIG1H Options --------------------------------------------------
    _FOSC_XT_XT_1H       EQU  H'F0'    ; XT oscillator, XT used by USB
    _FOSC_XTPLL_XT_1H    EQU  H'F2'    ; XT oscillator, PLL enabled, XT used by USB
    _FOSC_ECIO_EC_1H     EQU  H'F4'    ; External clock, port function on RA6, EC used by USB
    _FOSC_EC_EC_1H       EQU  H'F5'    ; External clock, CLKOUT on RA6, EC used by USB
    _FOSC_ECPLLIO_EC_1H  EQU  H'F6'    ; External clock, PLL enabled, port function on RA6, EC used by USB
    _FOSC_ECPLL_EC_1H    EQU  H'F7'    ; External clock, PLL enabled, CLKOUT on RA6, EC used by USB
    _FOSC_INTOSCIO_EC_1H EQU  H'F8'    ; Internal oscillator, port function on RA6, EC used by USB
    _FOSC_INTOSC_EC_1H   EQU  H'F9'    ; Internal oscillator, CLKOUT on RA6, EC used by USB
    _FOSC_INTOSC_XT_1H   EQU  H'FA'    ; Internal oscillator, XT used by USB
    _FOSC_INTOSC_HS_1H   EQU  H'FB'    ; Internal oscillator, HS used by USB
    _FOSC_HS_1H          EQU  H'FC'    ; HS oscillator, HS used by USB
    _FOSC_HSPLL_HS_1H    EQU  H'FE'    ; HS oscillator, PLL enabled, HS used by USB

    and the OSCCON was right in the first post.

    Sorry mackrackit
    I goofed on on OSCCOM --%01101100 is what I meant, bit 2+3 turned on.

    INTCKO Ever have ONE OF THOSE DAYS when.... Thanks for letting me know that I am having one.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    and then ... bit 2+3 are read-Only... so writing 1 or 0 on these won't change anything... sorry again

    Ever have ONE OF THOSE DAYS when.... Thanks for letting me know that I am having one.
    Oh... trust me... i really understand... i recently have more than day(s) like that... count them in weeks and months....
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    and then ... bit 2+3 are read-Only... so writing 1 or 0 on these won't change anything... sorry again
    Well I have got bigger problems than I thought. I am trying to learn the 18F4320 and I realize you can read bits 2+3 , but the only way I can get the chip to run correctly is to set them high.

    Must have been a fluke, now I am going to try them low. I have only done a couple of projects with this chip.

    Just tried it on a data logger I am working on, now bits 2+3 do not make a difference.

    Learn something every day Thank you Mr.E
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    nice! You're welcome.

    Don't worry, we all learn new thing every day with those nifty black pinned boxes.

    Thanks to internet, forums and various Gurus all 'round the world. Really nice toolssssssssss!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  11. #11
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Hey guys,

    Thanks so much for your input. Much appreciated. _CPUDIV_OSC1_PLL2_1L fixed it. I now have the same problem on a 16f88 that I was trying to use with internal osc. It ran about 10 times slower than it should. I can't find any fuses relating to PLL. I was out of internet range (I work on a boat) so I put a resonator in the circuit and fixed it that way. Strange to have the same problem with 2 different chips when there is absolutely no relationship between the problems!! Well, there must be a fuse somewhere I can't recognise!

    Thanks again

    Rich

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well it's more than set a fuse, you also need to set the internal OSC register. Open the datasheet under OSCCON Section. If my memory serves me well, the default value is set to 32KHz

    And then if my memory still serves me well
    OSCCON=%01100000 ' will set the internal osc to 4MHz
    OSCCON=%01110000 ' will set the internal osc to 8MHz
    Last edited by mister_e; - 27th September 2007 at 14:13.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Thanks Mr_e!

    I actually tried 8mhz and 4mhz internal using the following settings:

    DEFINE OSC 8
    OSCCON=%01110000

    DEFINE OSC 4
    OSCCON=%01100000

    My fuse setting was INTRC. I can't find anything else of relevance to osc speed in fuses. It's not a major problem as ultimately I will use a 20mhz crystal but it would enhance my understanding for future projects to be able to use the internal osc.

    Cheers

    Rich

  14. #14
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Just a thought, have you read this? Post #6
    http://www.picbasic.co.uk/forum/show...ost13087#post6
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. 18F2550 timing
    By sstt1976 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 22nd August 2008, 01:30
  2. 18f2550 + 24lc512
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2007, 23:02
  3. Madness, 18F2550!
    By tom in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 11th February 2007, 12:00
  4. 18f2550 'access is denied' USB error?
    By Giulio in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 30th December 2006, 15:29
  5. EasyHid and 18F2550 - why? what? how?
    By Giulio in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 28th December 2006, 08:57

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