PIC18F25K22 Internal clock config...

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

PIC18F25K22 Internal clock config...

Post by saakis »

Hello Matrix and forum people!
Help me with config file for the pic 18f25k22. I want the internal oscillator 4x PLL and 16 MHz osc. So far I couldn't manage to do that... Give me a solution please!!!
Thank you!
Sakis
Attachments
18F25K50.fcdx
(30.94 KiB) Downloaded 297 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: PIC18F25K22 Internal clock config...

Post by Benj »

Hello Sakis,

Hopefully this should run as expected, let us know how you get on.
18F25K22.fcfx
(7.87 KiB) Downloaded 361 times

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: PIC18F25K22 Internal clock config...

Post by saakis »

Thank you for your reply Benj but it doesn't work. First didn't complete the compilation because the osccon was in capital letters(!). After that just bring the first word 0x55 and stop there. I tried to change some parameters from the config but no success...
Sakis

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: PIC18F25K22 Internal clock config...

Post by Benj »

Hello,

Sorry the register name was in v7 upper case format, v6 and earlier require lower case register names.
just bring the first word 0x55 and stop there.
Might be worth waiting a while, sounds like the device is running a lot slower than expected and hence the 1 second delay is taking many multiples of 1 second.

Try adding this to your C code after the osccon line to try and force the PLL to be enabled. You might also need to change the PLL config setting to disabled as it looks like the PLL and INTOSC can only be enabled via the osctune register.

Code: Select all

osctune = 0x40;  //Enable PLL
while ((osccon2 & 0x80) == 0);  //Wait for PLL to become stable
Let us know how you get on.

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: PIC18F25K22 Internal clock config...

Post by saakis »

Hi benj,
doing the config below, I have 4 sec pulce but changing the osccon to 70 it stucks. I need 4 times faster pulses. Maybe the PLL is not enabled...
Regards
Sakis
Attachments
18F25K22_mod.fcfx
(4.21 KiB) Downloaded 324 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: PIC18F25K22 Internal clock config...

Post by Benj »

Maybe try enabling the Internal/External Oscillator Switchover config setting, I seem to remember this helping on another device.

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: PIC18F25K22 Internal clock config...

Post by saakis »

Hi Benj, still refuse to work...any other idea or I will use a crystal?
Regards

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: PIC18F25K22 Internal clock config...

Post by Benj »

Hello Sakis,

There will be a way to do it, the datasheet says it can be done.

I would have a thorough read of section 2 of the datasheet and see if you can pull out any pearls of wisdom. Googling for example code can also be a good way.

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: PIC18F25K22 Internal clock config...

Post by saakis »

Hi Benj,
finally it works.The only problem I have is that if I enable both A6 & A7 as I/O the prossesor stuck after 1 sec. If the A6 is configured as a Clockout port the PIC is fine...One I/O less!
Thank you for your help!
Attachments
PIC18_TEST_1sec_prototype.fcfx
(8.33 KiB) Downloaded 331 times

Post Reply