Page 1 of 1

CLKOUT on the 18F66K80

Posted: Sat Feb 15, 2020 9:09 pm
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

Re: CLKOUT on the 18F66K80

Posted: Sun Feb 16, 2020 2:09 pm
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.

Re: CLKOUT on the 18F66K80

Posted: Mon Feb 17, 2020 12:22 pm
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

Re: CLKOUT on the 18F66K80

Posted: Mon Feb 17, 2020 1:41 pm
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.