View Full Version : ultra slow pic18F4550's
comwarrior
- 14th November 2010, 15:13
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.
mackrackit
- 14th November 2010, 16:08
More than likely your configs. Do they look like this?
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
comwarrior
- 14th November 2010, 17:29
Close...
Here is a copy of the chip setup...
What have i missed?
@ __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
mackrackit
- 14th November 2010, 17:48
Add this
OSCCON = %01110000
comwarrior
- 14th November 2010, 19:29
Shouldn't OSCCON bit 1 be set to 1 to select internal oscillator?
mackrackit
- 14th November 2010, 20:14
Nope. It will work as I posted.
Did you try it yet?
comwarrior
- 15th November 2010, 00:17
OK, yep that runs much better... more like expected.
Thank you mackrackit :)
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.