CLKOUT on the 18F66K80

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
Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

CLKOUT on the 18F66K80

Post by Lord Grezington »

Hi

I want to run the 18F66K80 at full speed (64Mhz), preferably using an external Xtal (but could use the INTOSC if need be), but I also want a CLKOUT at preferably 5Mhz (but could possibly push all the way up to 16Mhz) to run a few external components in sync.

Is this possible? I'm a little confused as the CLKOUT pin is on A6, bit the OCS1 & OSC2 pins are A6 & A7.

Also, how do I scale the CLKOUT frequency to 5Mhz (or 16Mhz if I really have to)?

I think I need to use the EC3IO, but not sure on how to implement it.

Thanks

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CLKOUT on the 18F66K80

Post by medelec35 »

Using clock out on RA6 is fine if you only want Fosc/4.
If you want a much wider choice, you can set REFOCON to give a much wider range (from fosc to fosc/32,768) on pin RC3.
See page 64 of the datasheet.
Martin

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: CLKOUT on the 18F66K80

Post by Lord Grezington »

Hi Martin

Thanks for this.

The project has some what progressed since writing the last post, I have now moved on to using the 33EP64MC206 for the addtional speed an IO. For this part the datasheet says it has a REFCLK0 that is remapable and easily set within the RECOCON register.

I have never re-mapped a pin using C before (only done it using the flowcode marco's). Any chance you could help with showing me an exampe of how I would re-map the REFCLK0 to one of the RP* pins?

Thanks

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: CLKOUT on the 18F66K80

Post by Benj »

Hello,

First find the RP number of the pin you wish to output the signal to. Note any pin marked RPIxx is only available as a remappable input.

Then look for the pin in the RPORx register section of the datasheet starting from page 197.

For example using RP20 the code woud look like this.

Code: Select all

RPOR0bits.RP20R = 0x31;
0x31 corresponds to the REFCLKO output.

Post Reply