PDA

View Full Version : Modified include files



Joe Rocci
- 14th August 2006, 15:16
I'm trying to modify the PIC18F2620 include files so that my programs will, by default, compile/assemble with the oscillator mode set to internal and 4MHz.

This line:
__CONFIG _CONFIG1H, _OSC_INTIO7_1H
will set the default oscillator mode to internal (with Fosc/4 coming out on RA6), but the default frequency for this mode seems to be 1MHz and not the 4MHz I want.

Can someone tell me how to add/modify the include file to set the frequency to 4MHz?

Thanks

Joe

Melanie
- 14th August 2006, 16:07
This is actually a 2-part process, not just a setting in the CONFIG bits but also within your program initialisation...

Go look at the DATASHEET section 2 for Ocillator Configurations, scroll down to the OSCCON Register settings... within your program you must set OSCCON for the speed you require as you've got 8 selections from 31kHz to 8MHz (default I believe is 1MHz). So within your program you must set something like...

OSCCON=%01100000

...and if you have timing critical functions, then follow that with...

WHILE OSCCON.2=0:WEND

to ensure your program pauses there until the Oscillator is stable.

Joe Rocci
- 14th August 2006, 18:39
Thanks Melanie,

I figured it all out and got it to work a little earlier today. I'm finally where I wanted to be a couple days ago...I have a Microcode Studio Plus compatible loader file that works with the PIC's internal oscillator.

I finally got it to work by disassembling the MicroCode Stuio loader hex file, finding the place where the UART initialization happens, modifying/adding some setups, and reassembling.

Works like a charm!


Joe