Jump to content

Recommended Posts

I am at the end my rope trying to get an 18F4550 to run with a crystal clock. I dont need the USB/PLL and just can't get the thing to work with the crystal clock.


I can get it to work with the internal 8 MHz clock (thanks to RSABEAR) but cant seem to find the correct setup for a 20MHz crystal.


My assumption is that the setup is buried somewhere in the config files, but I may be missing something is some of the other registers.


Here's what works for my with the internal 8 MHz oscillator:

// 8 Mhz Internal Clock
#pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
#pragma DATA _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
#pragma DATA _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
#pragma DATA _CONFIG7H, _EBTRB_OFF_7H</P> <P>
#pragma CLOCK_FREQ	8000000  </P> <P>
osccon = 0b01110010;   (in main)

Link to post
Share on other sites

Hi Rye,


The closest chip I have is an 18F4455 which is basically the same thing.


I changed the clock source to HS and added a 20MHz xtal. Also removed any code bank 3 stuff.




Chip is running a treat on my EasyPIC5 board with your config data.





Link to post
Share on other sites

Hi Reynard:


Thanks for verifying my thinking on the config1h setup. I had tried that several times before and tried it again.....and it didn't work again. Then it occured to me that it might be a hardware problem -- being a retired hardware engineer that seemed highly unlikely ;) , but....... A detailed look-see of the crystal wiring showed that I didn't have pin 14 connected to the crystal. :angry: duh uh!

Because of the apparent complexity of the config registers I was totally focused on them. Your comment somehow got me thinking in another direction. Thanks again.


I now have an interrupt driven timer, a 9.6k serial port and PWM working on the 18F4550 if any of that might be of help to you. None of them are much different from the 16F877, but it's still slow going making sure that there is nothing buried in the manual that I might have missed.


The 18F4550 is being used to generate a pure/stable 20Hz sine wave via class D (PWM) modulation of the PWM port. It works quite well with the second harmonic being about 36dB down from the fundamental and the rest are well below -40dB.




Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...