Page 1 of 1

PIC18F2520 problem with OSCCON register

Posted: Thu Feb 15, 2018 1:15 pm
by maharadga
Hello.
I use FC7 and I try make simple programm with internal oscillator enabled.
I added C-code in the begining of programm and set internall oscillator in options.
But PIC is work very slow. I want it be work on 8MHz.
Where is my mistake?

Re: PIC18F2520 problem with OSCCON register

Posted: Thu Feb 15, 2018 1:19 pm
by Benj
Hello,

That all looks correct to me. Have you tried the 1 second flash test to try and see what speed your actually running at?

https://www.matrixtsl.com/wikiv7/index. ... ED_flasher

Re: PIC18F2520 problem with OSCCON register

Posted: Thu Feb 15, 2018 1:59 pm
by maharadga
Thanks for the quick answer.
I found mistake. In test circuit board MCLR is unpinned.
I want PLL 4 MHz frequency in this mode/int osc/ to be 16MHz.
Do I do it right?
Because if I set 16MHz in options LED flash 4 times slow. If I set 4MHz it's Ok.

Re: PIC18F2520 problem with OSCCON register

Posted: Thu Feb 15, 2018 2:32 pm
by maharadga
I solved it. Must change order of C-code

OSCTUNE=0x5F;
OSCCON=0x60;

to

OSCCON=0x60;
OSCTUNE=0x5F;

and frequency in settings must be 16MHz.
Apparently the order of writing is important.