PD equ 0x17 VER equ 0x07 ; ------------------------------------------------------------------------ ; ; Title: ; ; PD17 -- PIC 1/2.5/5/10 MHz to 1 PPS frequency divider, with sync ; ; Function: ; ; This PIC program implements a digital frequency divider: the external ; 1, 2.5, 5, or 10 MHz input clock is divided down to 1 Hz (1 pulse per ; second). Two pins are used to configure the frequency division ratio. ; ; ---o--- ; (Vdd) +5 V ++++|1 8|==== ground (Vss) ; n MHz clock in >---|2 12F 7|+--< CfgA ; 1PPS out <---|3 6xx 6|+--< CfgB ; ARM >--*|4 5|+--< SYNC ; ------- ; Notes: ; ; - The 1PPS output has 10% duty cycle (100 ms pulse width). ; - 1PPS rising edge can be synchronized using ARM-SYNC control pins. ; - Output frequency accuracy is the same as clock input accuracy. ; - Jitter is below 1 ps (the PIC is a fully synchronous device). ; - Internal weak pull-up on pins 7,6,5; external pull-up on pin 4. ; - Coded for PIC 12F675 but any '609 '615 '629 '635 '675 '683 works. ; ; Version: ; ; 30-Jul-2008 Tom Van Baak (tvb) http://www.LeapSecond.com/pic ; ; ------------------------------------------------------------------------ ; Define processor, fuses, register base, and interrupt vectors. list p=pic12f675 include "p12f675.inc" __config _EC_OSC & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON cblock 0x20 endc org 0 ; power-on entry goto init dw PD, VER org 4 ; (4) interrupt entry goto sync ; (2) ; One-time PIC 12F675 initialization. init: bcf STATUS,RP0 ; bank 0 clrf GPIO ; set outputs low movlw 0x07 ; turn comparator off movwf CMCON ; bsf STATUS,RP0 ; bank 1 errorlevel -302 clrf ANSEL ; all digital (no analog) pins movlw ~(1<