I'm currently using the PIC18F45K20 for my project. I would like to know if there is any need of configuration of software if I'm using an external clock (8MHz crystal oscillator). The external clock I am using is 2 ceramic capacitor connected to the crystal and the other end of the capacitors are grounded. The software I am using is the MPLAB IDE X v 1.41. If a configuration is needed how do I configure the PIC?
As Leon said, all of these things are pretty clearly explained in the datasheet.
Page 29: Bits 1-0 of the OSCCON register define the system clock selection.
SCS<1:0>: System Clock Select bits 1x = Internal oscillator block 01 = Secondary (Timer1) oscillator 00 = Primary clock (determined by CONFIG1H[FOSC<3:0>]).
The power up-default for this is 00.
Page 300: The default / unprogrammed value for CONFIG1H as 00xx0111. The last four bits are the FOSC oscillator selection bits:
FOSC<3:0>: Oscillator Selection bits 11xx = External RC oscillator, CLKOUT function on RA6 101x = External RC oscillator, CLKOUT function on RA6 1001 = Internal oscillator block, CLKOUT function on RA6, port function on RA7 1000 = Internal oscillator block, port function on RA6 and RA7 0111 = External RC oscillator, port function on RA6 0110 = HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1) 0101 = EC oscillator, port function on RA6 0100 = EC oscillator, CLKOUT function on RA6 0011 = External RC oscillator, CLKOUT function on RA6 0010 = HS oscillator 0001 = XT oscillator 0000 = LP oscillator
So, unless you change the config bits yourself, the part will expect an external RC oscillator.
You most likely will need to / want to change other things, so from your project go to Window -> PIC Memory Views -> Configuration Bits, set things up as you need them, then copy the generated code into your project.
You should always set the configuration bits in your code. MPLAB may default to something usable when running with a debugger, but any such defaults don't go into the HEX file. You want to make sure that the HEX file can stand on its own, and not require MPLAB and with your special settings to program into a part. Even then, I don't think MPLAB defaults config settings all the time.
Again, not specifying all config bits in your source code is a really bad idea.