PDA

View Full Version : Oscillator configuration for PIC18f2455



Fritzengruber
- 4th September 2006, 13:32
Hi everyone,
I am new to the world of Pic processors, and am having a bit of a problem. I am using a pic18f2455 on a custom made board to act as a motor controller by switching FETs, and have noticed that the chip seems to be running at 1/8th of the speed it should (a pause 1000 pauses 8 seconds instead of 1). I am not using the USB facilities, so I do not have an external oscillator,but am planning on just using the 8mhz internal oscillator. Using the command

DEFINE OSC 8

in picbasic doesnt seem to work, and leaving the oscillator speed undefined causes the chip to run at 1/4 speed.

Is there some other configuration option I should be changing? Do I have to change the config bits?

I just got this job after the guy before me was arrested, so I am having to pick up where he left off.

Thanks for your help

Fritz

sayzer
- 4th September 2006, 14:01
Why arrested?

Was he working on something illegal?
Are you continuing on his work?

Fritzengruber
- 4th September 2006, 15:21
Yes he was, but it had nothing to do with the project

mister_e
- 4th September 2006, 16:33
DEFINE OSC 8

in picbasic doesnt seem to work, and leaving the oscillator speed undefined causes the chip to run at 1/4 speed.

Is there some other configuration option I should be changing? Do I have to change the config bits?
sur eit have something to do with the config fuses... open then 18F2455.inc file in the PBP folder... you'll find those


__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L

change them to


try to change with
[code]
__CONFIG _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

and at the top of your code add


DEFINE OSC 8
OSCCON=%01110000

it should work... i should. Refer to the datasheet section 2.0

mark_wotton
- 5th September 2006, 07:18
On behalf of Fritzengruber, who is now busily removing no-longer-needed 20MHz oscillator crystals, thank you very much - you've saved our bacon. If you're in Doha any time in the next 4 months, or in Sydney after that, look me up (Mark Wotton) and I'll buy you a beer or twelve. :)

Cheers
Mark

mister_e
- 5th September 2006, 13:55
Twelve should be enough to start ;)

Nice to know it's working!