PIC18F4620 frequency

Thread Starter

sakishrist

Joined Dec 4, 2009
26
Hello,

I have a problem setting the frequency of the 18F4620 PIC. In the datasheet it's written that if I do not have a crystal I can select one of the following frequencies: 8 MHz,4 MHz,2 MHz,1 MHz,500 kHz,125 kHz,250 kHz,31 kHz. The problem is: how do I choose one? I have set the OSC to internal but anything else I try to modify (e.g.OSCCON) I get an error from mplab that it can't recognize it.

Thanks
 

eng1ne

Joined Dec 4, 2009
97
Post the line of code you are using to define the OSCCON register; not really sure what you are asking.

If you haven't already, look at page 30 of the datasheet, and alter bits 6-4 depending on your desired frequency.
 

Thread Starter

sakishrist

Joined Dec 4, 2009
26
Thanks for the reply. That is the page I'm on. I'm setting theese values in the code:
Rich (BB code):
#pragma config PWRT = OFF, WDT = OFF, LVP = OFF
The rest of them are set from the "Configuration Bits" windows (shown in the attachment). So how do I set the OSCCON bits? When I attempt to I get a weird error message: "Error [1224] configuration setting 'OSCCON' not recognized". So how should I change the Frequency of the PIC?

Thanks :)
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
Configuration bits are written into the PIC at programming time and can't be changed.
OSCCON is just an ordinary register that you set from within the program.
I don't understand C but in ASM it would be
movlw b'00000000' ;(or whatever bits you want to set)
movwf OSCCON
 
Top