;controller for elcom dfs1201 ;dual freq ;12000 because it seems ok! ;11880 gives 46656 (432 IF for 47088) ; David Robinson WW2R ; aug 19 2005 ; for int rc osc ; GP5 GP4 GP3 GP2 GP1 GP0 ; SCLK DOUT freq CS freq freq ; PIN2 PIN3 pin4 pin 5 PIN6 PIN7 LIST P=12F675, R=DEC ; Use the PIC12F675 and decimal system #include "P12F675.INC" ; Include header file __FUSES _CP_OFF &_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF &_BODEN_OFF &_MCLRE_OFF cblock 0x20 r_temp count ncount kcount mcount xcount run bits f1_1 f1_2 f1_3 f1_4 f2_1 f2_2 f2_3 f2_4 f3_1 f3_2 f3_3 f3_4 f4_1 f4_2 f4_3 f4_4 endc org 0 ;Initialize ports. banksel GPIO clrf GPIO movlw 0x7f movwf CMCON banksel TRISIO ;select pg1 movlw B'0001011' ;set gp0-5 as outputs, except 3 1 0 input movwf TRISIO movlw B'00000000' ;select digital operation of input movwf ANSEL banksel GPIO ;select pg0 movlw 0x08 movwf bits call ce_high call delay1s call delay1s call delay1s call delay1s call delay1s ;values for freq 11800MHz ...remember to multiply frequency by 3 ;freq 1 - GPIO 3-0, GPIO 1-0, GPIO 0-0 movlw 0x35 movwf f3_1 movlw 0x40 movwf f3_2 movlw 0x00 movwf f3_3 movlw 0x00 movwf f3_4 ;values for freq 11800MHz ...remember to multiply frequency by 3 ;freq 2 - GPIO 3-1, GPIO 1-0, GPIO 0-0 movlw 0x35 movwf f3_1 movlw 0x40 movwf f3_2 movlw 0x00 movwf f3_3 movlw 0x00 movwf f3_4 ;values for freq 11800MHz ...remember to multiply frequency by 3 ;freq 1 - GPIO 3-0, GPIO 1-1, GPIO 0-0 movlw 0x35 movwf f3_1 movlw 0x40 movwf f3_2 movlw 0x00 movwf f3_3 movlw 0x00 movwf f3_4 ;values for freq 11806,6 ...remember to multiply frequency by 3 ;freq 4 - GPIO 3-0, GPIO 1-0, GPIO 0-1 movlw 0x35 movwf f4_1 movlw 0x42 movwf f4_2 movlw 0x00 movwf f4_3 movlw 0x00 movwf f4_4 ;decide which freq to output btfsc GPIO,3 goto freq2 btfsc GPIO,1 goto freq3 btfsc GPIO,0 goto freq4 ; send values to oscillator (32 bits) for freq1 freq1 bsf GPIO,0 bcf GPIO,1 call ce_low call wait movf f1_4,0 call spi_nbit_word ;send next 8 bits movf f1_3,0 call spi_nbit_word ;send next 8 bits ; movf f1_2,0 call spi_nbit_word ;send next 8 bits movf f1_1,0 call spi_nbit_word ;send next 8 bits call wait call ce_high call wait loopf1 btfsc GPIO,3 goto freq2 btfsc GPIO,1 goto freq3 btfsc GPIO,0 goto freq4 goto loopf1 ; send values to oscillator (32 bits) for freq2 freq2 bcf GPIO,0 bsf GPIO,1 call ce_low call wait movf f2_4,0 call spi_nbit_word ;send next 8 bits movf f2_3,0 call spi_nbit_word ;send next 8 bits ; movf f2_2,0 call spi_nbit_word ;send next 8 bits movf f2_1,0 call spi_nbit_word ;send next 8 bits call wait call ce_high call wait loopf2 btfsc GPIO,1 goto freq3 btfsc GPIO,0 goto freq4 btfsc GPIO,3 goto loopf2 goto freq1 ; send values to oscillator (32 bits) for freq3 freq3 bsf GPIO,0 bcf GPIO,1 call ce_low call wait movf f3_4,0 call spi_nbit_word ;send next 8 bits movf f3_3,0 call spi_nbit_word ;send next 8 bits ; movf f3_2,0 call spi_nbit_word ;send next 8 bits movf f3_1,0 call spi_nbit_word ;send next 8 bits call wait call ce_high call wait loopf3 btfsc GPIO,3 goto freq2 btfsc GPIO,0 goto freq4 btfsc GPIO,3 goto loopf3 goto freq1 ; send values to oscillator (32 bits) for freq4 freq4 bcf GPIO,0 bsf GPIO,1 call ce_low call wait movf f4_4,0 call spi_nbit_word ;send next 8 bits movf f4_3,0 call spi_nbit_word ;send next 8 bits ; movf f4_2,0 call spi_nbit_word ;send next 8 bits movf f4_1,0 call spi_nbit_word ;send next 8 bits call wait call ce_high call wait loopf4 btfsc GPIO,3 goto freq2 btfsc GPIO,1 goto freq3 btfsc GPIO,0 goto loopf4 goto freq1 ;************ spi_nbit_word ;************ movwf r_temp ;r_temp = 8 bits of data to send movf bits,w ;number of bits to w movwf ncount ;number of bits to ncount btfline1 btfsc r_temp,0 ;test bit 7 of r_temp skip if clear goto spi_hi1 rrf r_temp,f ;spi_low call wait bsf GPIO,5 ;sclk=0 call wait bcf GPIO,5 ;sclk=1 call wait decfsz ncount,1 goto btfline1 goto lp_end spi_hi1 rrf r_temp,f ;spi high bsf GPIO,4 ;Din=1 call wait bsf GPIO,5 ;sclk=0 call wait bcf GPIO,5 ;sclk=1 call wait bcf GPIO,4 ;Din=0 decfsz ncount,1 goto btfline1 lp_end return ce_low bcf GPIO,2 ;cs\=0 call wait return ce_high bsf GPIO,2 ;cs\=1 call wait return wait movlw 0xff ;was 80 movwf count ;to kcount deck decfsz count,f ;dec k goto deck return ;******** delay1s ;******** movlw 0x32 ;0x32 to w movwf xcount ;to xcount loadm2 movlw 0x1a ;0x1a to w 1a and ff give 10ms per loop movwf mcount ;to mcount at 4MHz loadk2 movlw 0xff movwf kcount deck2 decfsz kcount,f goto deck2 decfsz mcount,f goto loadk2 decfsz xcount,f; goto loadm2 ; return ORG 0X100 dw 'W' dw 'W' dw '2' dw 'R' dw ' ' dw 'E' dw 'L' dw 'C' dw 'O' dw 'M' dw ' ' dw 'C' dw 'O' dw 'N' dw 'T' dw 'R' dw 'O' dw 'L' dw 'L' dw 'E' dw 'R' dw ' ' dw 'V' dw '2' dw '.' dw '1' dw ' ' dw 'B' dw 'Y' dw ' ' dw 'O' dw 'K' dw '1' dw 'V' dw 'M' END