PDA

View Full Version : The confi fuses for pic18f4550 in Epic programmer



sammy
- 23rd May 2006, 15:31
Hi all:
I am having a hell of a time programming the pic18f4550 due to its so many clock options. I have been able to get every thing to work if i use a 4MHz ceramic resonator and the XT option from the fuse config menue. The problem occures when i use a 20MHz resonator.
I use the command Define osc 20 but the timing is still off. I tried to send serial data and the timing is all off.
any ideas

thanx


sam

ErnieM
- 23rd May 2006, 20:04
Time for a sanity check. Forget your project for a while, make something simple work.

Measure the clock frequency. Is it really 20 meg?

Make a loop timed with a PAUSE to wiggle a pin up and down. Is it the right period?

Sorry I can't be of more help with the serial commands as I've yet to use them.

Bruce
- 23rd May 2006, 22:36
Be sure to set HS in config word. This forces the PIC oscillator drive output
to a higher level required to drive the high-speed oscillator.

The default config word osc setting in 18F4550.INC header file is for XT.

Look in your PBP directory for 18F4550.INC, and change XT to HS, or change
XT to HS with your programmer software before programming the part.

sammy
- 24th May 2006, 16:04
Thanx for the reply Bruce. The problem I am having however is not with the compiler but the programmer. In the MElabs programming softwear for the EPIC I can change the configuration fuses. My understanding was that with a 20MHz ceramic resinator if i select Osillator type as HSPLL for Pic18f4550 and use the pll divisions as 5 with the mcu clock division as 2 this should give me a frequency of 48MHz. This is according to the data sheet. however when i do this and try to send data through port B.7 at 9600, the data actually comes in at 115200. I do define the osc at 48 in the program. this is the problem.
any ideas
thanx
sam

Bruce
- 24th May 2006, 16:53
Sorry. Your original post indicates DEFINE OSC 20 with a 20MHz osc. I didn't know you were trying this at 48MHz.

If you're changing config settings with your EPIC software, and you have the "Reread File Before Programming" and "Update Configuration From File" options checked, then it's going to reload whatever config word settings are embedded in your .hex file before programming the part.

You should click Save before programming to use whatever config word changes you made. Then program it.

With a 20MHz crystal, PIC18F4550, and this osc configuration;

CONFIG PLLDIV=5,CPUDIV=OSC1_PLL2,FOSC=HSPLL_HS

This works perfectly at 9600;

SEROUT2 PORTB.7,16468, ["TEST",13,10]

If you prefer to use 20MHz without HSPLL, just change FOSC=HSPLL_HS to FOSC=HS and DEFINE OSC 48 to DEFINE OSC 20.

This also works 100%. At least on my board.

sammy
- 25th May 2006, 01:36
Again Thank you very much Bruce but I still cant get the thing to work. I am getting lcoser though. when you say to write the
CONFIG PLLDIV=5,CPUDIV=OSC1_PLL2,FOSC=HSPLL_HS in the softwear, do i need to add a @ before the word config. I tried this with both the @ and without and the compiler gave me errors both times. what is the exact wording that i need to type into my program
thanx again
sam

Bruce
- 25th May 2006, 02:01
Hi Sam,

No. These are "config fuse" settings. You set them by adding the config directive to your code, editing the 18F4550.INC file in your PBP directory, or select them with your programmers software before programming the part.

Look at the clock diagram in your 18F4550 data sheet so you can follow this;

PLLDIV=5 divides the 20MHz crystal input x5 for 4MHz output on the PLL Prescaler.

Note where it shows (4MHz input only) to the 96MHz PLL block? That's why you use the PLL prescaler. The output can only be 4MHz no matter what the primary oscillator speed is when it's input to the HS PLL.

CPUDIV=OSC1_PLL2 divides the 96MHz PLL input to the PLL Postscaler x2 to provide 48MHz system clock to the CPU core.

FOSC = HSPLL_HS simply enables the high-speed PLL clock multiplier.

These are only available at program time, and can only be configured at the time you initially program the PIC.

DEFINE OSC 48, 20, etc, does nothing but inform PBP as to the osc clock frequency you're using so it can internally adjust/include PBP library functions to work at the specified clock speed.

I won't re-hash something Melanie has already covered, so take a peek at this thread; http://www.picbasic.co.uk/forum/showthread.php?t=543

The new USB parts definitely have a boat-load of oscillator options, but once you get the hang of it, they are really fun to mess with.

If you're still confused after reading Melanies thread & comparing the above to the data sheet let me know.

sammy
- 27th May 2006, 20:50
Hi Bruce:
Thanx for the advice. I have been pulling my hair out of my head non the less. I dont think the problem is in the fuse config any more. I understand how the fuses work but they are not doing what they are suppose to be doing. not sure why. here is what i am doing. I gave up on the 20MHz resonator and i am using the 4MHz resinator. I set the PLLDIV to 1 so to give me 96 Mhz. I also set the oscillator type to XTPLL and the PLL postscaler to 2. so this should give me 48MHz for the CPU clock. this is all done via the epic programmer.
the Program i am testing is as follows:


define OSC 48

loop:
serout portb.7,2,["test"]
pause 1000
goto loop

now when i run the program the data is not comming in at 9600 but is actually comming in at 115200. I tried replacing XTPLL to HSPLL but no change. I even tried doing OSC 4 and still nothing changed. the program i am using for compiling is microcode studio and the version of my compiler is 2.46. the chip is programmed via an epic programmer with the softwear version of 4.1 beta.
any other help you can give me will be greatly apriciated.
thanx
sam