; ------------------------------------------------------------------------ ; ; Title: ; ; PD48 -- PIC 48 kHz to 100 Hz frequency divider for DECT ; ; Function: ; ; This PIC program implements a digital frequency divider: the external ; input clock is divided by a factor of 480. Given a 48 kHz input clock ; the output frequency is 100 Hz (10 ms period). ; ; The output waveform is unusual: the pulse width is 500 us except every ; 16th pulse is 5 ms wide. All periods are aligned at the falling edge. ; ; For details see Digital Enhanced Cordless Telecommunications (DECT): ; "this signal establishes the 10 ms DECT frame interval and the ; 160 ms DECT multiframe interval" ; ; The pins are "T2-mini" compatible (pin2 clock input, pin3 pulse ouput). ; ; Diagram: ; ---__--- ; 5V (Vdd) +++++|1 8|===== Ground (Vss) ; 48 kHz clock ---->|2 pD 7|- ; 100 Hz output <----|3 48 6|- ; o|4 5|- ; -------- ; Notes: ; ; Only 4 pins are required: power (2.0-5.5V), ground, input and output. ; o Pull or tie unused pin4 to Vdd or Vss. ; - Other unused pins may be left open. ; Output frequency accuracy is the same as clock input accuracy. ; Output drive current is 25 mA maximum per pin. ; Coded for Microchip 12F675 but any '609 '615 '629 '635 '675 '683 works. ; ; Version: ; ; 21-Sep-2014 Tom Van Baak (tvb) www.LeapSecond.com/pic ; ; ------------------------------------------------------------------------ ; Microchip MPLAB IDE assembler code (mpasm). list p=pic12f675 include p12f675.inc __config _EC_OSC & _MCLRE_OFF & _WDT_OFF ; Register definitions. cblock 0x20 ; define register base count ; mod-16 counter endc ; Pin definitions. clock_pin equ 5 ; GP5/pin2 external 48 kHz clock input pulse_pin equ 4 ; GP4/pin3 100 Hz output ; One-time PIC 12F675 initialization. org 0 ; power-on entry here bcf STATUS,RP0 ; bank 0 clrf GPIO ; set all pins low movlw 07h ; set mode to turn movwf CMCON ; comparator off bsf STATUS,RP0 ; bank 1 clrf ANSEL-0x80 ; set digital IO (no analog A/D) movlw ~(1<