PIC10F322 XC8 Code – to get a clock reference output on PortA.2

Reference Clock Output allows you to, basically turn the PortA.2 pin into a clock out device that you can use to drive other devices that require a clock input (think Z80 Clock input)

What is nice you can program different clock freqs.

The internal OSC can be set to the following frequencies.

16 MHz
8 MHz (default power on value)
4 MHz
2 MHz
1 MHz
500 kHz
250 kHz

Take those, divide by 4  and you get the reference output.

Below is a screen shot from the reference showing the wave form on PortA.2 running at 16Mhz – thus a 4Mhz output.

PIC10F322  XC8 Code - Clock Reference Output

The code and include files can be found here in GitHub – https://github.com/JamieStarling/MCU_FUN/tree/master/Microchip/PIC10F322  clock_reference_output.c

#include "includes/10F322_deviceconfig.h"
#include "includes/osc.h"

void main(void) 
    enableClockReferenceOut ();