PDA

View Full Version : OSC problems...Still new



iphillipsca
- 3rd January 2005, 00:22
Ok, i can get the thing programmed and the led flashing at 4Mhz but not 20Mhz. Have a look below and any help appreciated.

DEFINE OSC 20
INCLUDE "modedefs.bas"
INCLUDE "ICDDEFS4.BAS"
' Example program from manual to blink an LED connected to PORTB.0 about once a second


Led Var Byte

loop:

High 0 ' Turn on LED connected to PORTB.0
Pause 100 ' Delay for .5 seconds

Low 0 ' Turn off LED connected to PORTB.0
Pause 100 ' Delay for .5 seconds
Goto loop

mister_e
- 3rd January 2005, 04:19
As i remind you're using PIC18F252. Right?!?

If you're using external 20Mhz Crystal or ceramic resonator, be sure that you have set you Programmer to HS oscillator. or include this config fuse line to the top of your program

@ __CONFIG _CONFIG1H, _HS_OSC_1H

if you get any compile error with the above line (overwriting previous address) you must open the 18f252.INC file in the PBP directory an place an ; before the line

__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H

this will skip the factory OSC definition

In some case using 20Mhz ceramic resonator or crystal on BreadBoard can cause you some problems too. If you're using Crystal, try to remove the capacitor on each crystal pin. Seems the ProtoBoard do some capacitive load that can interfer with the crystal itself.

BUT you can also use a lowest frequency resonator or crystal and multiply it, by 4, with the internal PLL of the PIC18f252 to get the frequency you need. For that, you must set HS-PLL config fuse.