PIC18F2520 problem with OSCCON register

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
maharadga
Posts: 71
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 17 times
Been thanked: 12 times
Contact:

PIC18F2520 problem with OSCCON register

Post 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?
Attachments
Int_Osc_Test.fcfx
(8.02 KiB) Downloaded 191 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: PIC18F2520 problem with OSCCON register

Post 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

maharadga
Posts: 71
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 17 times
Been thanked: 12 times
Contact:

Re: PIC18F2520 problem with OSCCON register

Post 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.
Attachments
Int_Osc_Test_Flasher.fcfx
(8.01 KiB) Downloaded 184 times

maharadga
Posts: 71
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 17 times
Been thanked: 12 times
Contact:

Re: PIC18F2520 problem with OSCCON register

Post 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.

Post Reply