ultra slow pic18F4550's


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default ultra slow pic18F4550's

    Ok, i seem to have several pic's that are running approximately 1,000 times too slow (maybe more).
    However, i can only confirm this because i've simulated it and the cycle time is in micro seconds and not seconds...

    I read something somewhere about calibration for the internal clock but can't find it again...
    is it the 8MHz internal clock that could be out, if so, can i use a 32KHz LP watch crystal to recalibrate?

    Any ideas, help, appreciated.

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


    Did you find this post helpful? Yes | No

    Default

    More than likely your configs. Do they look like this?

    Code:
    DEFINE OSC 8
    @ __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG    _CONFIG1H, _FOSC_INTOSCIO_EC_1H
    @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & 0DFh
    OSCCON = %01110000
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Close...

    Here is a copy of the chip setup...
    What have i missed?

    Code:
    @ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
    @ __CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H & _FCMEN_ON_1H & _IESO_OFF_1H
    @ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_OFF_2L
    @ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_32768_2H
    @ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H
    @ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_ON_4L &  _ICPRT_OFF_4L & _XINST_ON_4L & _DEBUG_OFF_4L
    
    Define  OSC				8						' Set clock speed
    
    ' Setup chip                                    
    INTCON.7 = 0                                    ' Disable interupts
    INTCON.6 = 0
    INTCON.5 = 0
    INTCON.4 = 0
    INTCON.3 = 0
    PIE1 = 0                                         ' Disable interupts
    
    T0CON.7 = 0                                     ' Disable TMR0
    T1CON.0 = 0                                     ' Disable TMR1
    T2CON.2 = 0                                     ' Disable TMR2
    T3CON.0 = 0                                     ' Disable TMR3
    
    ADCON0.0 = 1                                    ' Enable ADC module
    ADCON1.5 = 0
    ADCON1.4 = 0
    ADCON1.3 = 1                                    ' Set ADC ports
    ADCON1.2 = 0                                    ' Set ADC ports
    ADCON1.1 = 1                                    ' Set ADC ports
    ADCON1.0 = 0                                    ' Set ADC ports
    TRISE = %11000000								' Set PortE to all outputs
    TRISD = %00000000								' Set PortD to all outputs
    TRISC = %00000000								' Set PortC to all outputs
    TRISB = %00000000								' Set PortB to all outputs
    'TRISA = %00000000	 							' Set PORTA to all OUTPUTS
    
    ' initialise IO
    PORTA = %00000000                                ' Make Port low
    PORTB = %00000000                                ' Make Port low
    PORTC = %00000000                                ' Make Port low
    PORTD = %00000000                                ' Make Port low
    'PORTE = %00000000                                ' Make Port low

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


    Did you find this post helpful? Yes | No

    Default

    Add this
    OSCCON = %01110000
    Dave
    Always wear safety glasses while programming.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Shouldn't OSCCON bit 1 be set to 1 to select internal oscillator?

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


    Did you find this post helpful? Yes | No

    Default

    Nope. It will work as I posted.
    Did you try it yet?
    Dave
    Always wear safety glasses while programming.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    OK, yep that runs much better... more like expected.

    Thank you mackrackit

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