; ;Control program for HRPT receiver with 35MHz IF ; #include "P16C5X.INC" list p=16c54c ; ;Define registers ; #define synpoint H'008' ;points to current synth data #define datalen H'009' ;how many bits in current data sequence #define chanstr H'00A' ;previous channel selection #define chansel H'00B' ;current channel selection on switch or external interface #define bitctr H'00C' ;counts off bits in byte #define wordctr H'00D' ;counts off synth data words #define charbuff H'00E' ;store for synth data characters ; ;Define synth connections ; #define syndata PORTA,1 ;data #define synclk PORTA,2 ;clock #define synle PORTA,0 ;load enable ; ;Define valid input values for channel selections ; chan1 equ D'126' ;01111110 chan2 equ D'125' ;01111101 chan3 equ D'123' ;01111011 chan4 equ D'119' ;01110111 chan5 equ D'111' ;01101111 chan6 equ D'95' ;01011111 chan7 equ D'63' ;00111111 ; ;Set the reset vector to point to program start ; org H'1FF' goto start ; ;Program starts here ; org 0 ; ;Configure port A for input and clear FSR ; start movlw 0 ;set portA as output tris PORTA clrf FSR ; ;Reset the synth and set to chan 6 (1707MHz) ; ; ;First put synth in reset mode ; movlw D'20' ;set data length count movwf datalen movlw reset1-table ;point to reset1 data movwf synpoint call synthdata ; ;Then set the reference divider ; movlw D'21' movwf datalen movlw rcount-table ;point to R counter data movwf synpoint call synthdata ; ;Then set the default channel 1707MHz ; movlw D'21' movwf datalen movlw ch6-table ;point to channel 6 data movwf synpoint call synthdata ; ;Return from reset mode ; movlw D'20' movwf datalen movlw reset2-table movwf synpoint call synthdata movlw 0 ;set initial channel store value movwf chanstr ; ;Enter the main program loop ;Scan port A and look for change of input value. ;If any change, re-program the synth. ; loop movf PORTB,0 ;get channel select data to W andlw H'7F' ;mask off msb movwf chansel ;store channel selection xorwf chanstr,0 ;check for channel change btfsc STATUS,Z goto loop movf chansel,0 ;store the changed channel movwf chanstr xorlw chan1 ;check for channel 1 btfss STATUS,Z goto loop1 ;go if not chan 1.. movlw ch1-table ;else point to chan 1 data goto loop7 loop1 movf chanstr,0 ;get channel to W xorlw chan2 ;check for channel 2 btfss STATUS,Z goto loop2 ;go if not chan 2.. movlw ch2-table ;else point to chan2 data goto loop7 loop2 movf chanstr,0 ;get channel to W xorlw chan3 ;check for channel 3 btfss STATUS,Z goto loop3 ;go if not chan 3.. movlw ch3-table ;else point to chan3 data goto loop7 loop3 movf chanstr,0 ;get channel to W xorlw chan4 ;check for channel 4 btfss STATUS,Z goto loop4 ;go if not chan 4.. movlw ch4-table ;else point to chan4 data goto loop7 loop4 movf chanstr,0 ;get channel to W xorlw chan5 ;check for channel 5 btfss STATUS,Z goto loop5 ;go if not chan 5.. movlw ch5-table ;else point to chan5 data goto loop7 loop5 movf chanstr,0 ;get channel to W xorlw chan6 ;check for channel 6 btfss STATUS,Z goto loop6 ;go if not chan 5.. movlw ch6-table ;else point to chan6 data goto loop7 loop6 movlw ch7-table ;else point to chan7 data loop7 movwf synpoint ;store table pointer movlw D'21' ;set data length count movwf datalen call synthdata goto loop ; ;Send channel or reset data to the synthesiser. ;Following code is entered with synpoint and datalen set. ; synthdata bcf synclk ;clear clock bit bcf synle ;clear load enable synthdata1 movlw D'8' ;set bit counter movwf bitctr movf synpoint,0 ;put table offset pointer in W call getdata ;get character from table movwf charbuff ;temp store data byte incf synpoint,1 ;point to next data byte synthdata2 btfsc charbuff,7 ;check if msb clear.. goto synthdata3 ;if not go and set data bit.. bcf syndata ;else clear data bit.. goto synthdata4 ;and then send data bit synthdata3 bsf syndata ;set data bit synthdata4 nop bsf synclk ;pulse clock high.. bcf synclk ;and then low rlf charbuff,1 ;move to next data bit decf datalen,1 ;dec the length count.. decfsz bitctr,1 ;and the bit/byte count goto synthdata5 ;if bit/byte count not zero.. ;go test the length count.. goto synthdata1 ;else get the next byte synthdata5 movf datalen,1 ;test length count using Z btfss STATUS,Z ;if not zero.. goto synthdata2 ;process next bit.. bsf synle ;else send synth LE bcf synle retlw 0 ; ;Data tables ; getdata addwf PCL,1 ;offset into table table reset1 retlw 0 ;data to enter reset mode retlw D'8' retlw D'96' reset2 retlw 0 ;data to leave reset mode retlw D'8' retlw D'32' rcount retlw 0 ;reference counter data retlw D'12' retlw D'128' ; ;Frequency settings for 35Mhz IF ;Frequency in comments is actual receive frequency. The data programmes ;the synth to 35MHz below the receive frequency. ; ch1 retlw D'8' ;1698 retlw D'30' retlw D'200' ch2 retlw D'8' ;1700.4 retlw D'33' retlw D'200' ch3 retlw D'8' ;1700.5 retlw D'33' retlw D'168' ch4 retlw D'8' ;1702.4 retlw D'36' retlw D'104' ch5 retlw D'8' ;1704.5 retlw D'38' retlw D'232' ch6 retlw D'8' ;1707 retlw D'42' retlw D'8' ch7 retlw D'8' ;1707 retlw D'42' retlw D'8' end