• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1631
  • Last Modified:

How to set PIC 18F4431 internal oscilator

I am confused about how to set the internal oscillator for the PIC 18F4431. I would like to use the chip's internal oscillator and run it at its fastest speed but I am not sure how to do this. The OSC configuration bits and the OSCCON register are not clear to me. I am not sure what OSC = HS implies. Also, according to the datasheet, the fastest speed that OSCCON can be set to is 8 MHz but I read that the 18F4431 can run at 40 MHz. Please help! Thank you!
0
0av067
Asked:
0av067
1 Solution
 
HappyCactusCommented:
The PIC microprocessor can be set up with various oscillator configuration, with internal clock source or by providing an external clock (with an active oscillator or a quartz crystal).
In chapter 2of the datasheet (here), you can see all the configuration you can use.
"HS" mode means an "high speed resonator", that means you can use both a quartz crystal or a monolithic resonator. In the same page 21, you can see many suggested values for the resonation network capacitors.
Instead INTIO1 and INTIO2 are modes with the "internal clock source". Maximum frequencies for both modes are 8Mhz for internal clock source and 40MHz for external clock source with PLL enabled (10Mhz x 4).

As you can see in the pic18fxx31 microprocessor (pag. 26), the OSCCON register is a bit mapped register.
The ITF2:ITF0 bits sets the frequency of the internal oscillator. the "111" configuration drives the clock directly from the 8MHz internal clock source, overriding the post-scaler. This is the maximum frequency available without an external source.

If you want to reach 40MHz, you must use the HSPLL mode, and provide the clock externally. I suggest a good resonator and a good layout for your PCB. If you are using a breadboard / prototype board, check carefully how you connect the ground and the capacitors; be warned that in this condition your clock may be unstable and the cpu may work bad.

refer to the Chapter 2 of the datasheet for other information about the oscillator section of the CPU.

Hope that helps.
0
 
0av067Author Commented:
Apologies I simply forgot about this post. The answer covers everything regarding internal oscillator setup and even a little about external oscillator configs. I can't accept it as a solution, however, because of the above close request. I would like to accept with a grade of "A" as it was complete, accurate, and easy to follow. Thank you.
0
 
DhaestCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now