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 _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
#pragma DATA _CONFIG1H, _FOSC_INTOSCIO_EC_1H & _FCMEN_OFF_1H & _IESO_OFF_1H  
#pragma DATA  _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L  & _VREGEN_OFF_2L
#pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
#pragma DATA _CONFIG3H, _CCP2MX_OFF_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _MCLRE_ON_3H
#pragma DATA _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L & _XINST_OFF_4L
#pragma DATA _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
#pragma DATA _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
#pragma DATA _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
#pragma DATA _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
#pragma DATA _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
#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.

 

#pragma DATA _CONFIG1H, _FOSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H

 

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

 

Cheers

 

Reynard

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.

 

Cheers

Rye

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.

Guest
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.

Loading...
×
×
  • Create New...