MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;****************************************************************************** 00002 ; Source code used for Direct Digital Synthesis VFO 00003 ; 00004 ; Target Controller - PIC16F84 00005 ; __________ 00006 ; ENCODER SWITCH--RA2 |1 18| RA1---------ENCODER A 00007 ; PB SWITCH-------RA3 |2 17| RA0---------ENCODER B 00008 ; +5V-------------RA4 |3 16| OSC1--------XTAL 00009 ; Ground--------!MCLR |4 15| OSC2--------XTAL 00010 ; Ground----------Vss |5 14| VDD---------+5 V 00011 ; DDS LOAD--------RB0 |6 13| RB7---------DDS DATA/LCD 14 00012 ; LCD_rs----------RB1 |7 12| RB6---------LCD 13 00013 ; LCD_rw----------RB2 |8 11| RB5---------DDS CLOCK/LCD 12 00014 ; LCD_e-----------RB3 |9 10| RB4---------LCD 11 00015 ; ---------- 00016 ; 00017 ; Assembler - Parallax SPASM v4.7 00018 ; Author - Curtis W. Preuss - WB2V 00019 ; 00020 ; Modification History 00021 ; Initial Version 8/19/98 00022 ; 00023 ; Converted to MPASM by Bruce Stough, AA0ED inf 12/98 00024 ; 00025 ;****************************************************************************** 00026 ; Description: 00027 ; This is the control program for a DDS VFO built with an AD9850 DDS chip, a 00028 ; shaft encoder, a push button switch and an Liquid crystal display. 00029 ; 00030 ; Features: 00031 ; VARIABLE RATE TUNING based on the speed at which the encoder is turned. The 00032 ; encoder also has a built in switch which will change the step size from 1Hz 00033 ; to 1kHz if the encoder shaft is pressed down while turning. 00034 ; 00035 ; BAND MEMORIES an external push button switch allows the frequency to be 00036 ; cycled around the HF ham bands. 00037 ; 00038 ; CALIBRATE MODE is entered if the external push button is pressed during 00039 ; power on. The display is set to 10,000.000 CAL. If the push button is held 00040 ; pressed then turning the shaft encoder will increase or decrease the value 00041 ; "osc" used to calculated the DDS control word. A fast adjustment speed is 00042 ; available by pressing the encoder shaft down while turning. 00043 ; To exit calibrate mode, release the external push button and turn the shaft 00044 ; encoder one more time. The calibrated value of "osc" will then be stored in 00045 ; EEprom memory. 00046 ; 00047 ;****************************************************************************** 00048 ; Device type and options 00049 ; 00050 processor PIC16F84 00051 radix dec 00052 ; 00053 ;******************************************************************************* MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00054 ; Configuration fuse information: 00055 ; 2007 3FFD 00056 __config 0x3FFD 00057 ; Code protect OFF, Power-up timer ON, WDT ENABLED, XT Oscillator 00058 ; 00059 ;******************************************************************************* 00060 ; 00000005 00061 PortA equ 0x05 00000006 00062 PortB equ 0x06 00000005 00063 TRISA equ 0x05 00000006 00064 TRISB equ 0x06 00000008 00065 EEdata equ 0x08 00000009 00066 EEadr equ 0x09 00000002 00067 WREN equ 0x02 00000001 00068 WR equ 0x01 00000000 00069 RD equ 0x00 00070 ; 00071 ;******************************************************************************* 00072 ; ID location information: 00073 ; (MPASM warns about DW here, don't worry) 00074 ; 2000 00075 ORG 0x2000 Warning[220]: Address exceeds maximum range for this processor. 2000 007F 00076 DATA 0x007F Warning[220]: Address exceeds maximum range for this processor. 2001 007F 00077 DATA 0x007F Warning[220]: Address exceeds maximum range for this processor. 2002 007F 00078 DATA 0x007F Warning[220]: Address exceeds maximum range for this processor. 2003 007F 00079 DATA 0x007F 00080 ; 00081 ;******************************************************************************* 00082 ; User EEPROM data: 00083 ; 00084 ; The fourth byte "23h" is the integer part of 00085 ; (2**32 / oscillator_freq_in_Hertz). 00086 ; 00087 ; Bytes 3,2,1 "CAh, 91h, 70h" are the fractional_part_of 00088 ; (2**32 / oscillator_freq_in_Hertz) times 2**24. 00089 ; 2100 00090 ORG 0x2100 2100 0070 0091 00CA 00091 DATA 0x70,0x91,0xCA,0x23 ; Default oscillator frequency 0023 2104 0000 0000 0000 00092 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 3 LOC OBJECT CODE LINE SOURCE TEXT VALUE 2122 0000 0000 0000 00093 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00094 ; 00095 ;******************************************************************************* 00096 ; RAM page independent file registers: 00097 ; 00000000 00098 INDF EQU 0x00 00000002 00099 PCL EQU 0x02 00000003 00100 STATUS EQU 0x03 00000004 00101 FSR EQU 0x04 0000000A 00102 PCLATH EQU 0x0A 0000000B 00103 INTCON EQU 0x0B 00104 ; 00105 ;******************************************************************************* 00106 ; 00107 ; Bit numbers for the STATUS file register: 00108 ; 00000005 00109 B_RP0 EQU 5 00000004 00110 B_NTO EQU 4 00000003 00111 B_NPD EQU 3 00000002 00112 B_Z EQU 2 00000001 00113 B_DC EQU 1 00000000 00114 B_C EQU 0 00115 ; 00116 ;******************************************************************************* 00117 ; Bit numbers for the INTCON file register: 00118 ; 00000007 00119 B_GIE EQU 7 00000006 00120 B_EEIE EQU 6 00000005 00121 B_T0IE EQU 5 00000004 00122 B_INTE EQU 4 00000003 00123 B_RBIE EQU 3 00000002 00124 B_T0IF EQU 2 00000001 00125 B_INTF EQU 1 00000000 00126 B_RBIF EQU 0 00127 ; 00128 ;******************************************************************************* 00129 ; Assign names to IO pins 00130 ; 00131 ; B register bits: 00132 ; 00000000 00133 DDS_load equ 0x00 ; Update pin on AD9850 00000001 00134 LCD_rs equ 0x01 ; 0=instruction, 1=data 00000002 00135 LCD_rw equ 0x02 ; 0=write, 1=read 00000003 00136 LCD_e equ 0x03 ; 0=disable, 1=enable MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 4 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00000005 00137 DDS_clk equ 0x05 ; AD9850 write clock 00000007 00138 DDS_dat equ 0x07 ; AD9850 serial data input 00139 ; 00140 ; A register bits: 00141 ; 00000003 00142 PbSwitch equ 0x03 ; Calibrate Push Button, (active low) 00143 ; 00144 ;****************************************************************************** 00145 ;Allocate variables in general purpose register space 00146 ; 00147 CBLOCK 0x0c 0000000C 00148 freq ; Display frequency in hex (4 bytes) 0000000D 00149 freq_2, freq_3, freq_4 00000010 00150 bcd ; Display frequency in BCD (5 bytes) 00000011 00151 bcd_2, bcd_3, bcd_4, bcd_5 00000015 00152 AD9850 ; AD9850 control word (5 bytes) 00000016 00153 AD9850_2, AD9850_3, AD9850_4, AD9850_5 0000001A 00154 fstep ; Frequency inc/dec (4 bytes) 0000001B 00155 fstep_2, fset_3, fstep_4 0000001E 00156 bcdCount ; Used in BIN2BCD routine 0000001F 00157 bcdTemp ; " 00000020 00158 multCount ; Used in Calc_DDS_Word routine 00000021 00159 bitCount ; " 00000022 00160 byte2send ; 00000023 00161 osc ; (4 bytes) 00000024 00162 osc_2, osc_3, osc_4 00000027 00163 osc_temp ; Oscillator frequency (4 bytes) 00000028 00164 osc_temp_2, osc_temp_3, osc_temp_4 0000002B 00165 LCD_char ; Character being sent to the LCD 0000002C 00166 LCD_read ; Character read from the LCD 0000002D 00167 timer1 ; Used in delay routines 0000002E 00168 timer2 ; " 0000002F 00169 ren_timer ; For variable rate tuning (2 bytes) 00000030 00170 ren_timer_2 00000031 00171 ren_new ; New value of encoder pins A and B 00000032 00172 ren_old ; Old value of encoder pins A and B 00000033 00173 ren_read ; Encoder pins A and B and switch pin 00000034 00174 Last_dir ; Indicates last direction of encoder 00000035 00175 Next_dir ; Indicates expected direction 00000036 00176 W_copy ; Used by interrupt handler 00000037 00177 S_copy ; " 00000038 00178 count ; loop counter (gets reused) 00000039 00179 band ; Used to index a table of frequencies 00180 ENDC 00181 ; 00182 ;***************************************************************************** 00183 ;The 16F84 resets to 000h, Interrupt vector is at 004h 00184 ; 0000 00185 ORG 0x0000 0000 00186 reset_entry 0000 280C 00187 goto start ; Jump to the beginning of the program 00188 ; 0004 00189 ORG 0x0004 MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 5 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00190 ;****************************************************************************** 00191 ; Interrupt handler saves copies of the W and STATUS registers on entry 00192 ; and restores the original register values on exit. 00193 ; 0004 00194 isr_entry 0004 00B6 00195 movwf W_copy ; Make a copy of w. 0005 0803 00196 movf STATUS,w ; Make a copy of status. 0006 00B7 00197 movwf S_copy ; Location = 0x0006 00198 ; 00199 ;interupt stuff goes here 0007 00200 . 00201 ; 0007 0837 00202 movf S_copy,w ; Restore STATUS 0008 0083 00203 movwf STATUS ; 0009 0EB6 00204 swapf W_copy,f ; Restore w without changing STATUS 000A 0E36 00205 swapf W_copy,w ; 000B 0009 00206 retfie ; 00207 ;******************************************************************************* 000C 00208 start 000C 018B 00209 clrf INTCON ; No interrupts for now 000D 1683 00210 bsf STATUS,B_RP0 ; Switch to bank 1 000E 1781 00211 bsf 0x01,7 ; Disable weak pullups 000F 30FF 00212 movlw 0xFF ; Tristate port A 0010 0085 00213 movwf TRISA ; 0011 0186 00214 clrf TRISB ; Set port B to all outputs 0012 1283 00215 bcf STATUS,B_RP0 ; Switch back to bank 0 00216 ;****************************************************************************** 00217 ; Power on initialization of Liquid Crystal Display. 00218 ; The LCD controller chip must be equivalent to an Hitachi 44780. 00219 ; The LCD is assumed to be a 16 X 1 display. 00220 ; 0013 22ED 00221 call Wait128 ; Wait for LCD to power up 0014 3030 00222 movlw b'00110000' ; LCD init instruction 0015 0086 00223 movwf PortB ; Send to LCD 0016 1586 00224 bsf PortB,LCD_e ; Pulse the LCD E line 0017 22ED 00225 call Wait128 ; Wait a bit 0018 1186 00226 bcf PortB,LCD_e ; Clear E 0019 3030 00227 movlw b'00110000' ; LCD init instruction 001A 0086 00228 movwf PortB ; Send to LCD 001B 1586 00229 bsf PortB,LCD_e ; Pulse E 001C 22F0 00230 call Wait64 ; 001D 1186 00231 bcf PortB,LCD_e ; 001E 3030 00232 movlw b'00110000' ; LCD init instruction 001F 0086 00233 movwf PortB ; Send to LCD 0020 1586 00234 bsf PortB,LCD_e ; Pulse E 0021 22F0 00235 call Wait64 ; 0022 1186 00236 bcf PortB,LCD_e ; 0023 3020 00237 movlw b'00100000' ; 4-bit mode instruction 0024 0086 00238 movwf PortB ; Send to LCD 0025 1586 00239 bsf PortB,LCD_e ; Pulse E 0026 22F3 00240 call Wait32 ; 0027 1186 00241 bcf PortB,LCD_e ; 0028 3028 00242 movlw 0x28 ; 2 line display MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 6 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0029 00AB 00243 movwf LCD_char ; 002A 22A4 00244 call Cmnd2LCD ; 002B 3008 00245 movlw 0x08 ; Display off 002C 00AB 00246 movwf LCD_char ; 002D 22A4 00247 call Cmnd2LCD ; 002E 3001 00248 movlw 0x01 ; Clear and reset cursor 002F 00AB 00249 movwf LCD_char ; 0030 22A4 00250 call Cmnd2LCD ; 0031 3006 00251 movlw 0x06 ; Set cursor move direction 0032 00AB 00252 movwf LCD_char ; 0033 22A4 00253 call Cmnd2LCD ; 0034 300C 00254 movlw 0x0C ; Cursor blink off, display on 0035 00AB 00255 movwf LCD_char ; 0036 22A4 00256 call Cmnd2LCD ; 00257 ; 00258 ;Enter Calibrate Mode if push button is pressed while turning the power on. 00259 ; 0037 1985 00260 btfsc PortA,PbSwitch ; Is the switch pressed? 0038 283A 00261 goto readEEocs ; No, get clock freq from EEprom 0039 2158 00262 call Calibrate ; Yes, calibrate 003A 00263 readEEocs 003A 0189 00264 clrf EEadr ; Reset the EEprom read address 003B 22E5 00265 call ReadEE ; Read EEprom 003C 0808 00266 movf EEdata,w ; Get the first osc byte 003D 00A3 00267 movwf osc ; Save osc frequency 003E 22E5 00268 call ReadEE ; Get next byte 003F 0808 00269 movf EEdata,w ; 0040 00A4 00270 movwf osc+1 ; Save it 0041 22E5 00271 call ReadEE ; Get the third byte 0042 0808 00272 movf EEdata,w ; 0043 00A5 00273 movwf osc+2 ; Save it 0044 22E5 00274 call ReadEE ; Get the fourth byte 0045 0808 00275 movf EEdata,w ; 0046 00A6 00276 movwf osc+3 ; Save it 00277 ; 00278 ; Set the power on frequency to 14.025. 00279 ; 0047 3028 00280 movlw 0x28 ; First byte 0048 008C 00281 movwf freq ; Save it 0049 3001 00282 movlw 0x01 ; Second byte 004A 008D 00283 movwf freq+1 ; Save it 004B 30D6 00284 movlw 0xD6 ; Third byte 004C 008E 00285 movwf freq+2 ; Save it 004D 3000 00286 movlw 0x00 ; Fourth byte 004E 008F 00287 movwf freq+3 ; Save it 00288 ; 00289 ; Display the power on frequency. 00290 ; 004F 2207 00291 call BIN2BCD ; Convert it to BCD 0050 2237 00292 call ShowFreq ; Display it 00293 ; 00294 ; Send power on frequency to the DDS chip. 00295 ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 7 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0051 21B7 00296 call Calc_DDS_Word ; Convert to delta value 0052 21ED 00297 call Send_DDS_Word ; Put 9850 in serial mode 0053 21ED 00298 call Send_DDS_Word ; Sends the power on frequency 00299 ; 00300 ; Get the power on encoder value. 00301 ; 0054 0805 00302 movf PortA,w ; Read port A 0055 00B3 00303 movwf ren_read ; Save it in ren_read 0056 3003 00304 movlw 0x03 ; Get encoder mask 0057 0533 00305 andwf ren_read,w ; Get encoder bits 0058 00B2 00306 movwf ren_old ; Save in ren_old 00307 ; 00308 ; Initialize variables. 00309 ; 0059 01B0 00310 clrf ren_timer+1 ; 005A 3040 00311 movlw 0x40 ; 005B 00AF 00312 movwf ren_timer ; 005C 01B4 00313 clrf Last_dir ; 005D 01B9 00314 clrf band ; 00315 ; 00316 ;****************************************************************************** 00317 ; This is the Main Program Loop 00318 ; The program's main loop "MAIN" calls PollEncoder which continuously polls the 00319 ; rotary shaft encoder. When the shaft encoder has changed then the direction 00320 ; it moved is determined and stored in "Last_dir" the subroutine then returns to 00321 ; to MAIN. 00322 ; 00323 ; If the push button swith was not pressed then the variable "fstep" is 00324 ; calculated based on the delay between shaft encoder changes, ("ren_timer" 00325 ; contains the delay value determined by the PollEncoder subroutine). 00326 ; The variable "fstep" is added or subtracted from the current VFO frequency 00327 ; stored in "freq". The contents of "freq" are then converted to a BCD 00328 ; number in subroutine "BIN2BCD". The subroutine "ShowFreq" is then called to 00329 ; display the result on the Liquid Crystal Display. Next, the subroutine 00330 ; "Calc_DDS_Word" is used to calculate the DDS frequency control word from the 00331 ; values in "freq" and "osc". The result is stored in "AD9850". This data 00332 ; is transferred to the AD9850 DDS chip by calling the subroutine "Send_DDS_Word". 00333 ; 00334 ; If the push button is pressed while turning the encoder then "freq" is loaded 00335 ; with a constant stored in "BandTable". The variable "band" is used as an index 00336 ; into the table. "Band" is incremented or decremented based on the 00337 ; encoder direction. 00338 ; 005E 00339 Main 005E 212E 00340 call PollEncoder ; Check for knob movement 005F 1DB3 00341 btfss ren_read,3 ; Change band? 0060 287C 00342 goto changeBand ; Yes, change bank 00343 ; 00344 ; Determine step size to use (1 Hz or 1 kHz). 00345 ; 0061 019D 00346 clrf fstep+3 ; 0062 019C 00347 clrf fstep+2 ; 0063 019B 00348 clrf fstep+1 ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 8 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0064 3001 00349 movlw 0x01 ; 1 Hz step if encoder switch is false 0065 009A 00350 movwf fstep ; 0066 1933 00351 btfsc ren_read,2 ; 0067 2872 00352 goto goStep ; Apply 0068 30E8 00353 movlw 0xE8 ; 1 kHz step if encoder switch is true 0069 009A 00354 movwf fstep ; 006A 3003 00355 movlw 0x03 ; 006B 009B 00356 movwf fstep+1 ; 006C 2872 00357 goto goStep ; Apply 00358 ; 00359 ; Adjust the tuning step based on ren_timer. 00360 ; 006D 00361 bumpstep 006D 1003 00362 bcf STATUS,B_C ; 006E 0D9A 00363 rlf fstep,f ; 006F 0D9B 00364 rlf fstep+1,f ; 0070 0D9C 00365 rlf fstep+2,f ; 0071 0D9D 00366 rlf fstep+3,f ; 0072 00367 goStep 0072 0DAF 00368 rlf ren_timer,f ; 0073 0DB0 00369 rlf ren_timer+1,f ; 0074 1C03 00370 btfss STATUS,B_C ; 0075 286D 00371 goto bumpstep ; 0076 18B4 00372 btfsc Last_dir,1 ; 0077 287A 00373 goto up ; 0078 00374 down 0078 2107 00375 call sub_step ; 0079 288F 00376 goto write ; 007A 00377 up 007A 20CB 00378 call add_step ; 007B 288F 00379 goto write ; 007C 00380 changeBand 007C 18B4 00381 btfsc Last_dir,1 ; 007D 2888 00382 goto bandUp ; 007E 3004 00383 movlw 0x04 ; 007F 02B9 00384 subwf band,f ; 0080 30DF 00385 movlw 0xDF ; 0081 0739 00386 addwf band,w ; 0082 1C03 00387 btfss STATUS,B_C ; 0083 2886 00388 goto valid ; 0084 3020 00389 movlw 0x20 ; 0085 00B9 00390 movwf band ; 0086 00391 valid 0086 20B9 00392 call GetBand ; 0087 288F 00393 goto write ; 0088 00394 bandUp 0088 3004 00395 movlw 0x04 ; Table entries are 4 bytes apart 0089 07B9 00396 addwf 0x39,f ; 008A 30DF 00397 movlw 0xDF ; 008B 0739 00398 addwf band,w ; 008C 1803 00399 btfsc STATUS,B_C ; 008D 01B9 00400 clrf band ; 008E 20B9 00401 call GetBand ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 9 LOC OBJECT CODE LINE SOURCE TEXT VALUE 008F 00402 write 008F 2207 00403 call BIN2BCD ; 0090 2237 00404 call ShowFreq ; 0091 21B7 00405 call Calc_DDS_Word ; 0092 21ED 00406 call Send_DDS_Word ; 0093 285E 00407 goto Main ; continue polling the encoder 00408 ; 00409 ;******************************************************************************* 00410 ; 0094 00411 BandTable 0094 0782 00412 addwf PCL,f ; 0095 3400 00413 retlw 0x00 ; 160 meters 0096 341B 00414 retlw 0x1B ; 0097 3477 00415 retlw 0x77 ; 0098 3440 00416 retlw 0x40 ; 0099 3400 00417 retlw 0x00 ; 80 meters 009A 3435 00418 retlw 0x35 ; 009B 3467 00419 retlw 0x67 ; 009C 34E0 00420 retlw 0xE0 ; 009D 3400 00421 retlw 0x00 ; 40 meters 009E 346A 00422 retlw 0x6A ; 009F 34CF 00423 retlw 0xCF ; 00A0 34C0 00424 retlw 0xC0 ; 00A1 3400 00425 retlw 0x00 ; 30 meters 00A2 349A 00426 retlw 0x9A ; 00A3 341D 00427 retlw 0x1D ; 00A4 3420 00428 retlw 0x20 ; 00A5 3400 00429 retlw 0x00 ; 20 meters 00A6 34D5 00430 retlw 0xD5 ; 00A7 349F 00431 retlw 0x9F ; 00A8 3480 00432 retlw 0x80 ; 00A9 3401 00433 retlw 0x01 ; 17 meters 00AA 3413 00434 retlw 0x13 ; 00AB 34B2 00435 retlw 0xB2 ; 00AC 3420 00436 retlw 0x20 ; 00AD 3401 00437 retlw 0x01 ; 15 meters 00AE 3440 00438 retlw 0x40 ; 00AF 346F 00439 retlw 0x6F ; 00B0 3440 00440 retlw 0x40 ; 00B1 3401 00441 retlw 0x01 ; 12 meters 00B2 347B 00442 retlw 0x7B ; 00B3 34CA 00443 retlw 0xCA ; 00B4 3490 00444 retlw 0x90 ; 00B5 3401 00445 retlw 0x01 ; 10 meters 00B6 34AB 00446 retlw 0xAB ; 00B7 343F 00447 retlw 0x3F ; 00B8 3400 00448 retlw 0x00 ; 00449 ; 00450 ;******************************************************************************* 00451 ; 00B9 00452 GetBand 00B9 0839 00453 movf band,w ; 00BA 2094 00454 call BandTable ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 10 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00BB 008F 00455 movwf freq+3 ; 00BC 0AB9 00456 incf band,f ; 00BD 0839 00457 movf band,w ; 00BE 2094 00458 call BandTable ; 00BF 008E 00459 movwf freq+2 ; 00C0 0AB9 00460 incf band,f ; 00C1 0839 00461 movf band,w ; 00C2 2094 00462 call BandTable ; 00C3 008D 00463 movwf freq+1 ; 00C4 0AB9 00464 incf band,f ; 00C5 0839 00465 movf band,w ; 00C6 2094 00466 call BandTable ; 00C7 008C 00467 movwf freq ; 00C8 3003 00468 movlw 0x03 ; 00C9 02B9 00469 subwf band,f ; Restore original value of band 00CA 0008 00470 return ; 00471 ; 00472 ;******************************************************************************* 00473 ; 00CB 00474 add_step 00CB 081A 00475 movf fstep,w ; 00CC 078C 00476 addwf freq,f ; 00CD 1C03 00477 btfss STATUS,B_C ; 00CE 28D4 00478 goto add1 ; 00CF 0F8D 00479 incfsz freq+1,f ; 00D0 28D4 00480 goto add1 ; 00D1 0F8E 00481 incfsz freq+2,f ; 00D2 28D4 00482 goto add1 ; 00D3 0A8F 00483 incf freq+3,f ; 00D4 00484 add1 00D4 081B 00485 movf fstep+1,w ; 00D5 078D 00486 addwf freq+1,f ; 00D6 1C03 00487 btfss STATUS,B_C ; 00D7 28DB 00488 goto add2 ; 00D8 0F8E 00489 incfsz freq+2,f ; 00D9 28DB 00490 goto add2 ; 00DA 0A8F 00491 incf freq+3,f ; 00DB 00492 add2 00DB 081C 00493 movf fstep+2,w ; 00DC 078E 00494 addwf freq+2,f ; 00DD 1C03 00495 btfss STATUS,B_C ; 00DE 28E0 00496 goto add3 ; 00DF 0A8F 00497 incf freq+3,f ; 00E0 00498 add3 00E0 081D 00499 movf fstep+3,w ; 00E1 078F 00500 addwf freq+3,f ; 00501 ; 00502 ; Peg the maximum VFO output frequency to 00503 ; a predetermined value, (1C9C380 is 30 MHz) 00504 ; 00E2 30FE 00505 movlw 0xFE ; 00E3 070F 00506 addwf freq+3,w ; 00E4 1803 00507 btfsc STATUS,B_C ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 11 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00E5 28FE 00508 goto setMax ; 00E6 3001 00509 movlw 0x01 ; 00E7 020F 00510 subwf freq+3,w ; 00E8 1C03 00511 btfss STATUS,B_C ; 00E9 2906 00512 goto exit1 ; 00EA 3036 00513 movlw 0x36 ; 00EB 070E 00514 addwf freq+2,w ; 00EC 1803 00515 btfsc STATUS,B_C ; 00ED 28FE 00516 goto setMax ; 00EE 30C9 00517 movlw 0xC9 ; 00EF 020E 00518 subwf freq+2,w ; 00F0 1C03 00519 btfss STATUS,B_C ; 00F1 2906 00520 goto exit1 ; 00F2 303C 00521 movlw 0x3C ; 00F3 070D 00522 addwf freq+1,w ; 00F4 1803 00523 btfsc STATUS,B_C ; 00F5 28FE 00524 goto setMax ; 00F6 30C3 00525 movlw 0xC3 ; 00F7 020D 00526 subwf freq+1,w ; 00F8 1C03 00527 btfss STATUS,B_C ; 00F9 2906 00528 goto exit1 ; 00FA 3080 00529 movlw 0x80 ; 00FB 020C 00530 subwf freq,w ; 00FC 1C03 00531 btfss STATUS,B_C ; 00FD 2906 00532 goto exit1 ; 00FE 00533 setMax 00FE 3080 00534 movlw 0x80 ; 00FF 008C 00535 movwf freq ; 0100 30C3 00536 movlw 0xC3 ; 0101 008D 00537 movwf freq+1 ; 0102 30C9 00538 movlw 0xC9 ; 0103 008E 00539 movwf freq+2 ; 0104 3001 00540 movlw 0x01 ; 0105 008F 00541 movwf freq+3 ; 0106 00542 exit1 0106 0008 00543 return ; 00544 ; 00545 ;******************************************************************************* 00546 ; 0107 00547 sub_step 0107 099A 00548 comf fstep,f ; Subtraction of fstep from 0108 099B 00549 comf fstep+1,f ; freq is down by adding the 0109 099C 00550 comf fstep+2,f ; twos compliment of fstepto 010A 099D 00551 comf fstep+3,f ; freq. 010B 0F9A 00552 incfsz fstep,f ; 010C 2912 00553 goto compDone ; 010D 0F9B 00554 incfsz fstep+1,f ; 010E 2912 00555 goto compDone ; 010F 0F9C 00556 incfsz fstep+2,f ; 0110 2912 00557 goto compDone ; 0111 0A9D 00558 incf fstep+3,f ; 0112 00559 compDone 0112 20CB 00560 call add_step ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 12 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00561 ; 00562 ; Peg the minimum VFO output frequency to 00563 ; a predetermined value, (3E8 is 1 kHz). 00564 ; 0113 1B8F 00565 btfsc 0x0F,7 ; Is number negative? 0114 2927 00566 goto setMin ; Yes, set minimum 0115 088F 00567 movf freq+3,f ; 0116 1D03 00568 btfss STATUS,B_Z ; 0117 292D 00569 goto exit2 ; 0118 088E 00570 movf freq+2,f ; 0119 1D03 00571 btfss STATUS,B_Z ; 011A 292D 00572 goto exit2 ; 011B 3003 00573 movlw 0x03 ; 011C 020D 00574 subwf freq+1,w ; 011D 1C03 00575 btfss STATUS,B_C ; 011E 2927 00576 goto setMin ; 011F 30FC 00577 movlw 0xFC ; 0120 070D 00578 addwf freq+1,w ; 0121 1803 00579 btfsc STATUS,B_C ; 0122 292D 00580 goto exit2 ; 0123 3017 00581 movlw 0x17 ; 0124 070C 00582 addwf freq,w ; 0125 1803 00583 btfsc STATUS,B_C ; 0126 292D 00584 goto exit2 ; 0127 00585 setMin 0127 30E8 00586 movlw 0xE8 ; 0128 008C 00587 movwf freq ; 0129 3003 00588 movlw 0x03 ; 012A 008D 00589 movwf freq+1 ; 012B 018E 00590 clrf freq+2 ; 012C 018F 00591 clrf freq+3 ; 012D 00592 exit2 012D 0008 00593 return 00594 ; 00595 ;******************************************************************************* 00596 ; 012E 00597 PollEncoder 012E 01B0 00598 clrf ren_timer+1 ; Put starting values in ren_timer 012F 3040 00599 movlw 0x40 ; 0130 00AF 00600 movwf ren_timer ; 0131 00601 read_encoder 0131 0064 00602 clrwdt ; Reset the watchdog timer 0132 1BB0 00603 btfsc ren_timer+1,7 ; 0133 2938 00604 goto noInc ; 0134 3008 00605 movlw 0x08 ; 0135 07AF 00606 addwf ren_timer,f ; 0136 1803 00607 btfsc STATUS,B_C ; 0137 0AB0 00608 incf ren_timer+1,f ; 0138 00609 noInc 0138 0805 00610 movf PortA,w ; Get the current encoder value 0139 00B3 00611 movwf ren_read ; Save it 013A 3003 00612 movlw 0x03 ; Get encoder mask 013B 0533 00613 andwf ren_read,w ; Isolate encoder bits MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 13 LOC OBJECT CODE LINE SOURCE TEXT VALUE 013C 00B1 00614 movwf ren_new ; Save new value 013D 0632 00615 xorwf ren_old,w ; Has it changed? 013E 1903 00616 btfsc STATUS,B_Z ; 013F 2931 00617 goto read_encoder ; No, keep looking until it changes 00618 ; 00619 ; Determine which direction the encoder turned. 00620 ; 0140 1003 00621 bcf STATUS,B_C ; Clear the carry bit 0141 0DB2 00622 rlf ren_old,f ; 0142 0831 00623 movf ren_new,w ; 0143 06B2 00624 xorwf ren_old,f ; 0144 0832 00625 movf ren_old,w ; 0145 3902 00626 andlw 0x02 ; 0146 00B5 00627 movwf Next_dir ; 0147 0634 00628 xorwf Last_dir,w ; 00629 ; 00630 ; Prevent encoder slip from giving a false change in direction. 00631 ; 0148 1903 00632 btfsc STATUS,B_Z ; Zero? 0149 294F 00633 goto continue ; No slip; keep going 014A 0835 00634 movf Next_dir,w ; Yes, update direction 014B 00B4 00635 movwf Last_dir ; 014C 0831 00636 movf ren_new,w ; 014D 00B2 00637 movwf ren_old ; 014E 2931 00638 goto read_encoder ; 014F 00639 continue 014F 18B2 00640 btfsc ren_old,1 ; 0150 2953 00641 goto up2 ; 0151 01B4 00642 clrf Last_dir ; 0152 2955 00643 goto exit3 ; 0153 00644 up2 0153 3002 00645 movlw 0x02 ; 0154 00B4 00646 movwf Last_dir ; 0155 00647 exit3 0155 0831 00648 movf ren_new,w ; 0156 00B2 00649 movwf ren_old ; 0157 0008 00650 return ; 00651 ; 00652 ;******************************************************************************* 00653 ; 0158 00654 Calibrate 0158 3080 00655 movlw 0x80 ; Set frequency to 10MHz 0159 008C 00656 movwf freq ; 0159 015A 3096 00657 movlw 0x96 ; Location = 0x015A 015B 008D 00658 movwf freq+1 ; 015C 3098 00659 movlw 0x98 ; 015D 008E 00660 movwf freq+2 ; 015E 3000 00661 movlw 0x00 ; 015F 008F 00662 movwf freq+3 ; 0160 3006 00663 movlw 0x06 ; Load the default oscillator freq 0161 00A3 00664 movwf osc ; 0162 30F0 00665 movlw 0xF0 ; 0163 00A4 00666 movwf osc+1 ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 14 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0164 30CA 00667 movlw 0xCA ; 0165 00A5 00668 movwf osc+2 ; 0166 3023 00669 movlw 0x23 ; 0167 00A6 00670 movwf osc+3 ; 0168 2207 00671 call BIN2BCD ; 0169 2237 00672 call ShowFreq ; 016A 30C4 00673 movlw 0xC4 ; Point LCD at digit 14 016B 00AB 00674 movwf LCD_char ; 016C 22A4 00675 call Cmnd2LCD ; 016D 3043 00676 movlw 0x43 ; Send a C 016E 00AB 00677 movwf LCD_char ; 016F 22BE 00678 call Data2LCD ; 0170 3041 00679 movlw 0x41 ; Send an A 0171 00AB 00680 movwf LCD_char ; 0172 22BE 00681 call Data2LCD ; 0173 304C 00682 movlw 0x4C ; Send an L 0174 00AB 00683 movwf LCD_char ; 0175 22BE 00684 call Data2LCD ; 0176 00685 Cal_Loop 0176 21B7 00686 call Calc_DDS_Word ; 0177 21ED 00687 call Send_DDS_Word ; 0178 212E 00688 call PollEncoder ; 0179 019D 00689 clrf fstep+3 ; 017A 019C 00690 clrf fstep+2 ; 017B 019B 00691 clrf fstep+1 ; 017C 3010 00692 movlw 0x10 ; Slow adjust 017D 009A 00693 movwf fstep ; 017E 1933 00694 btfsc ren_read,2 ; 017F 2982 00695 goto updateOSC ; 0180 3080 00696 movlw 0x80 ; Fast adjust 0181 009A 00697 movwf fstep ; 0182 00698 updateOSC 0182 0000 00699 nop ; 0183 18B4 00700 btfsc Last_dir,1 ; 0184 2990 00701 goto faster ; 00702 ; 00703 ; slower 00704 ; 0185 099A 00705 comf fstep,f ; Subtraction of fstep is done by 0186 099B 00706 comf fstep+1,f ; adding the twos compliment of fsetp 0187 099C 00707 comf fstep+2,f ; to osc 0188 099D 00708 comf fstep+3,f ; 0189 0F9A 00709 incfsz fstep,f ; 018A 2990 00710 goto faster ; 018B 0F9B 00711 incfsz fstep+1,f ; 018C 2990 00712 goto faster ; 018D 0F9C 00713 incfsz fstep+2,f ; 018E 2990 00714 goto faster ; 018F 0A9D 00715 incf fstep+3,f ; 0190 00716 faster 0190 081A 00717 movf fstep,w ; 0191 07A3 00718 addwf osc,f ; 0192 1C03 00719 btfss STATUS,B_C ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 15 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0193 2999 00720 goto add4 ; 0194 0FA4 00721 incfsz osc+1,f ; 0195 2999 00722 goto add4 ; 0196 0FA5 00723 incfsz osc+2,f ; 0197 2999 00724 goto add4 ; 0198 0AA6 00725 incf osc+3,f ; 0199 00726 add4 0199 081B 00727 movf fstep+1,w ; 019A 07A4 00728 addwf osc+1,f ; 019B 1C03 00729 btfss STATUS,B_C ; 019C 29A0 00730 goto add5 ; 019D 0FA5 00731 incfsz osc+2,f ; 019E 29A0 00732 goto add5 ; 019F 0AA6 00733 incf osc+3,f ; 01A0 00734 add5 01A0 081C 00735 movf fstep+2,w ; 01A1 07A5 00736 addwf osc+2,f ; 01A2 1C03 00737 btfss STATUS,B_C ; 01A3 29A5 00738 goto add6 ; 01A4 0AA6 00739 incf osc+3,f ; 01A5 00740 add6 01A5 081D 00741 movf fstep+3,w ; 01A6 07A6 00742 addwf osc+3,f ; 01A7 1DB3 00743 btfss ren_read,3 ; 01A8 2976 00744 goto Cal_Loop ; 01A9 0189 00745 clrf EEadr ; Write final value to EEprom 01AA 0823 00746 movf osc,w ; 01AB 0088 00747 movwf EEdata ; 01AC 22D8 00748 call WriteEE ; 01AD 0824 00749 movf osc+1,w ; 01AE 0088 00750 movwf EEdata ; 01AF 22D8 00751 call WriteEE ; 01B0 0825 00752 movf osc+2,w ; 01B1 0088 00753 movwf EEdata ; 01B2 22D8 00754 call WriteEE ; 01B3 0826 00755 movf osc+3,w ; 01B4 0088 00756 movwf EEdata ; 01B5 22D8 00757 call WriteEE ; 01B6 0008 00758 return ; 00759 ; 00760 ;******************************************************************************* 00761 ; 00762 ; Multiply the 32 bit number for oscillator frequency times the 32 bit number 00763 ; for the displayed frequency. 00764 ; 01B7 00765 Calc_DDS_Word 01B7 0195 00766 clrf AD9850 ; Clear AD9850 retisters 01B8 0196 00767 clrf AD9850+1 ; 01B9 0197 00768 clrf AD9850+2 ; 01BA 0198 00769 clrf AD9850+3 ; 01BB 0199 00770 clrf AD9850+4 ; 01BC 3020 00771 movlw 0x20 ; Set move count 01BD 00A0 00772 movwf multCount ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 16 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01BE 0823 00773 movf osc,w ; 01BF 00A7 00774 movwf osc_temp ; 01C0 0824 00775 movf osc+1,w ; 01C1 00A8 00776 movwf osc_temp+1 ; 01C2 0825 00777 movf osc+2,w ; 01C3 00A9 00778 movwf osc_temp+2 ; 01C4 0826 00779 movf osc+3,w ; 01C5 00AA 00780 movwf osc_temp+3 ; 01C6 00781 mult_loop 01C6 1003 00782 bcf STATUS,B_C ; 01C7 1C27 00783 btfss osc_temp,0 ; 01C8 29E0 00784 goto noAdd ; 01C9 080C 00785 movf freq,w ; 01CA 0796 00786 addwf AD9850+1,f ; 01CB 1C03 00787 btfss STATUS,B_C ; 01CC 29D2 00788 goto add7 ; 01CD 0F97 00789 incfsz AD9850+2,f ; 01CE 29D2 00790 goto add7 ; 01CF 0F98 00791 incfsz AD9850+3,f ; 01D0 29D2 00792 goto add7 ; 01D1 0A99 00793 incf AD9850+4,f ; 01D2 00794 add7 01D2 080D 00795 movf freq+1,w ; 01D3 0797 00796 addwf AD9850+2,f ; 01D4 1C03 00797 btfss STATUS,B_C ; 01D5 29D9 00798 goto add8 ; 01D6 0F98 00799 incfsz AD9850+3,f ; 01D7 29D9 00800 goto add8 ; 01D8 0A99 00801 incf AD9850+4,f ; 01D9 00802 add8 01D9 080E 00803 movf freq+2,w ; 01DA 0798 00804 addwf AD9850+3,f ; 01DB 1C03 00805 btfss STATUS,B_C ; 01DC 29DE 00806 goto add9 ; 01DD 0A99 00807 incf AD9850+4,f ; 01DE 00808 add9 01DE 080F 00809 movf freq+3,w ; 01DF 0799 00810 addwf AD9850+4,f ; 01E0 00811 noAdd 01E0 0C99 00812 rrf AD9850+4,f ; 01E1 0C98 00813 rrf AD9850+3,f ; 01E2 0C97 00814 rrf AD9850+2,f ; 01E3 0C96 00815 rrf AD9850+1,f ; 01E4 0C95 00816 rrf AD9850,f ; 01E5 0CAA 00817 rrf osc_temp+3,f ; 01E6 0CA9 00818 rrf osc_temp+2,f ; 01E7 0CA8 00819 rrf osc_temp+1,f ; 01E8 0CA7 00820 rrf osc_temp,f ; 01E9 0BA0 00821 decfsz multCount,f ; 01EA 29C6 00822 goto mult_loop ; 01EB 0199 00823 clrf AD9850+4 ; 01EC 0008 00824 return ; 00825 ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 17 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00826 ;******************************************************************************* 00827 ; 00828 ; Send Control Word to AD9850 DDS chip. 00829 ; This routine does a serial data transfer to the AD9850. 00830 ; 01ED 00831 Send_DDS_Word 01ED 3015 00832 movlw AD9850 ; Point FSR at AD9850 01EE 0084 00833 movwf FSR ; 01EF 00834 next_byte 01EF 0800 00835 movf INDF,w ; 01F0 00A2 00836 movwf byte2send ; 01F1 3008 00837 movlw 0x08 ; Set counter to 8 01F2 00A1 00838 movwf bitCount ; 01F3 00839 next_bit 01F3 0CA2 00840 rrf byte2send,f ; Test if next bit is 1 or 0 01F4 1C03 00841 btfss STATUS,B_C ; Was it zero? 01F5 29FA 00842 goto send0 ; Yes, send zero 01F6 1786 00843 bsf PortB,7 ; No, send one 01F7 1686 00844 bsf PortB,5 ; Toggle write clock 01F8 1286 00845 bcf PortB,5 ; 01F9 29FD 00846 goto break ; 01FA 00847 send0 01FA 1386 00848 bcf PortB,7 ; Send zero 01FB 1686 00849 bsf PortB,5 ; Toggle write clock 01FC 1286 00850 bcf PortB,5 ; 01FD 00851 break 01FD 0BA1 00852 decfsz bitCount,f ; Has the whole byte been sent? 01FE 29F3 00853 goto next_bit ; No, keep going. 01FF 0A84 00854 incf FSR,f ; Start the next byte unless finished 0200 301A 00855 movlw AD9850+5 ; Next byte 0201 0204 00856 subwf FSR,w ; 0202 1C03 00857 btfss STATUS,B_C ; 0203 29EF 00858 goto next_byte ; 0204 1406 00859 bsf PortB,0 ; Send load signal to the AD9850 0205 1006 00860 bcf PortB,0 ; 0206 0008 00861 return ; 00862 ; 00863 ;******************************************************************************* 00864 ; 00865 ; This subroutine converts a 32 bit binary number to a 10 digit BCD number. 00866 ; The input value taken from freq(0 to 3) is preserved. 00867 ; The output is in bcd(0 to 4), each byte holds => (hi_digit,lo_digit), 00868 ; most significant digits are in bcd+4. This routine is a modified version of one 00869 ; described in MicroChip application note AN526. 00870 ; 0207 00871 BIN2BCD 0207 3020 00872 movlw 0x20 ; 0208 009E 00873 movwf bcdCount ; 0209 0190 00874 clrf bcd ; 020A 0191 00875 clrf bcd+1 ; 020B 0192 00876 clrf bcd+2 ; 020C 0193 00877 clrf bcd+3 ; 020D 0194 00878 clrf bcd+4 ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 18 LOC OBJECT CODE LINE SOURCE TEXT VALUE 020E 00879 loop 020E 1003 00880 bcf STATUS,B_C ; 020F 0D8C 00881 rlf freq,f ; 0210 0D8D 00882 rlf freq+1,f ; 0211 0D8E 00883 rlf freq+2,f ; 0212 0D8F 00884 rlf freq+3,f ; 0213 1803 00885 btfsc STATUS,B_C ; 0214 140C 00886 bsf 0x0C,0 ; 0215 0D90 00887 rlf bcd,f ; 0216 0D91 00888 rlf bcd+1,f ; 0217 0D92 00889 rlf bcd+2,f ; 0218 0D93 00890 rlf bcd+3,f ; 0219 0D94 00891 rlf bcd+4,f ; 021A 039E 00892 decf bcdCount,f ; 021B 1D03 00893 btfss STATUS,B_Z ; 021C 2A1E 00894 goto adjust ; 021D 0008 00895 return ; 021E 00896 adjust 021E 3010 00897 movlw 0x10 ; 021F 0084 00898 movwf FSR ; 0220 222A 00899 call adjBCD ; 0221 0A84 00900 incf FSR,f ; 0222 222A 00901 call adjBCD ; 0223 0A84 00902 incf FSR,f ; 0224 222A 00903 call adjBCD ; 0225 0A84 00904 incf FSR,f ; 0226 222A 00905 call adjBCD ; 0227 0A84 00906 incf FSR,f ; 0228 222A 00907 call adjBCD ; 0229 2A0E 00908 goto loop ; 022A 00909 adjBCD 022A 0800 00910 movf INDF,w ; 022B 009F 00911 movwf bcdTemp ; 022C 3033 00912 movlw 0x33 ; 022D 079F 00913 addwf bcdTemp,f ; 022E 0103 00914 clrw ; 022F 1D9F 00915 btfss 0x1F,3 ; 0230 3803 00916 iorlw 0x03 ; 0231 1F9F 00917 btfss 0x1F,7 ; 0232 3830 00918 iorlw 0x30 ; 0233 029F 00919 subwf bcdTemp,f ; 0234 081F 00920 movf bcdTemp,w ; 0235 0080 00921 movwf INDF ; 0236 0008 00922 return ; 00923 ; 00924 ;******************************************************************************* 00925 ; 00926 ; Display the frequency setting on LCD. 00927 ; 0237 00928 ShowFreq 0237 3081 00929 movlw 0x81 ; Point the LCD to digit number one. 0238 00AB 00930 movwf LCD_char ; 0239 22A4 00931 call Cmnd2LCD ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 19 LOC OBJECT CODE LINE SOURCE TEXT VALUE 023A 0813 00932 movf bcd+3,w ; Send the 10MHz digit 023B 00AB 00933 movwf LCD_char ; 023C 30F0 00934 movlw 0xF0 ; 023D 05AB 00935 andwf LCD_char,f ; 023E 0EAB 00936 swapf LCD_char,f ; 023F 3030 00937 movlw 0x30 ; 0240 04AB 00938 iorwf LCD_char,f ; 0241 22BE 00939 call Data2LCD ; 00940 ; 0242 0813 00941 movf bcd+3,w ; Send the 1MHz digit 0243 00AB 00942 movwf LCD_char ; 0244 300F 00943 movlw 0x0F ; 0245 05AB 00944 andwf LCD_char,f ; 0246 3030 00945 movlw 0x30 ; 0247 04AB 00946 iorwf LCD_char,f ; 0248 22BE 00947 call Data2LCD ; 00948 ; 0249 302C 00949 movlw ',' ; Send a comma 024A 00AB 00950 movwf LCD_char ; 024B 22BE 00951 call Data2LCD ; 00952 ; 024C 0812 00953 movf bcd+2,w ; Send the 100 kHz digit 024D 00AB 00954 movwf LCD_char ; 024E 30F0 00955 movlw 0xF0 ; 024F 05AB 00956 andwf LCD_char,f ; 0250 0EAB 00957 swapf LCD_char,f ; 0251 3030 00958 movlw 0x30 ; 0252 04AB 00959 iorwf LCD_char,f ; 0253 22BE 00960 call Data2LCD ; 00961 ; 0254 0812 00962 movf bcd+2,w ; Send the 10 kHz digit 0255 00AB 00963 movwf LCD_char ; 0256 300F 00964 movlw 0x0F ; 0257 05AB 00965 andwf LCD_char,f ; 0258 3030 00966 movlw 0x30 ; 0259 04AB 00967 iorwf LCD_char,f ; 025A 22BE 00968 call Data2LCD ; 00969 ; 025B 0811 00970 movf bcd+1,w ; Send the 1 kHz digit 025C 00AB 00971 movwf LCD_char ; 025D 30F0 00972 movlw 0xF0 ; 025E 05AB 00973 andwf LCD_char,f ; 025F 0EAB 00974 swapf LCD_char,f ; 0260 3030 00975 movlw 0x30 ; 0261 04AB 00976 iorwf LCD_char,f ; 0262 22BE 00977 call Data2LCD ; 00978 ; 0263 302E 00979 movlw '.' ; Send a period 0264 00AB 00980 movwf LCD_char ; 0265 22BE 00981 call Data2LCD ; 00982 ; 0266 30C0 00983 movlw 0xC0 ; Point to LCD digit number nine 0267 00AB 00984 movwf LCD_char ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 20 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0268 22A4 00985 call Cmnd2LCD ; 00986 ; 0269 0811 00987 movf bcd+1,w ; Send 100 Hz digit 026A 00AB 00988 movwf LCD_char ; 026B 300F 00989 movlw 0x0F ; 026C 05AB 00990 andwf LCD_char,f ; 026D 3030 00991 movlw 0x30 ; 026E 04AB 00992 iorwf LCD_char,f ; 026F 22BE 00993 call Data2LCD ; 00994 ; 0270 0810 00995 movf bcd,w ; Send 10 Hz digit 0271 00AB 00996 movwf LCD_char ; 0272 30F0 00997 movlw 0xF0 ; 0273 05AB 00998 andwf LCD_char,f ; 0274 0EAB 00999 swapf LCD_char,f ; 0275 3030 01000 movlw 0x30 ; 0276 04AB 01001 iorwf LCD_char,f ; 0277 22BE 01002 call Data2LCD ; 01003 ; 0278 0810 01004 movf bcd,w ; Send 1 Hz digit 0279 00AB 01005 movwf LCD_char ; 027A 300F 01006 movlw 0x0F ; 027B 05AB 01007 andwf LCD_char,f ; 027C 3030 01008 movlw 0x30 ; 027D 04AB 01009 iorwf LCD_char,f ; 027E 22BE 01010 call Data2LCD ; 01011 ; 027F 3020 01012 movlw ' ' ; Send a space 0280 00AB 01013 movwf LCD_char ; 0281 22BE 01014 call Data2LCD ; 01015 ; 0282 306B 01016 movlw 'k' ; Send a 'k' 0283 00AB 01017 movwf LCD_char ; 0284 22BE 01018 call Data2LCD ; 01019 ; 0285 3048 01020 movlw 'H' ; Send an "H" 0286 00AB 01021 movwf LCD_char ; 0287 22BE 01022 call Data2LCD ; 01023 ; 0288 307A 01024 movlw 'z' ; Send a 'z' 0289 00AB 01025 movwf LCD_char ; 028A 22BE 01026 call Data2LCD ; 01027 ; 028B 0008 01028 return ; 01029 ; 01030 ;******************************************************************************* 01031 ; 01032 ; Check if LCD is done with the last operation. 01033 ; 028C 01034 Busy_Check 028C 0186 01035 clrf PortB ; Clear outputs on PortB 028D 1683 01036 bsf STATUS,B_RP0 ; Switch to bank 1 028E 30F0 01037 movlw b'11110000' ; Set inputs MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 21 LOC OBJECT CODE LINE SOURCE TEXT VALUE 028F 0086 01038 movwf PortB ; 0290 1283 01039 bcf STATUS,B_RP0 ; Switch back to bank 0 0291 1086 01040 bcf PortB,LCD_rs ; Set up LCD for commands (RS) 0292 1506 01041 bsf PortB,LCD_rw ; Set up LCD for read 0293 30FF 01042 movlw 0xFF ; 0294 00AD 01043 movwf timer1 ; 0295 01044 lcd_is_busy 0295 1586 01045 bsf PortB,LCD_e ; 0296 0806 01046 movf PortB,w ; 0297 00AC 01047 movwf LCD_read ; 0298 1186 01048 bcf PortB,LCD_e ; 0299 0000 01049 nop ; 029A 0000 01050 nop ; 029B 1586 01051 bsf PortB,LCD_e ; 029C 0000 01052 nop ; 029D 1186 01053 bcf PortB,LCD_e ; 029E 03AD 01054 decf timer1,f ; Try it 255 times, then return anyway 029F 1903 01055 btfsc STATUS,B_Z ; 02A0 2AA3 01056 goto not_busy ; 02A1 1BAC 01057 btfsc LCD_read,7 ; 02A2 2A95 01058 goto lcd_is_busy ; 02A3 01059 not_busy 02A3 0008 01060 return ; 01061 ; 01062 ;******************************************************************************* 01063 ; 01064 ; Send Command to the LCD Subroutine. 01065 ; The command to be sent must in LCD_char before calling the subroutine. 01066 ; 02A4 01067 Cmnd2LCD 02A4 228C 01068 call Busy_Check ; 02A5 0186 01069 clrf PortB ; 02A6 1683 01070 bsf STATUS,B_RP0 ; Switch to bank 1 02A7 3000 01071 movlw 0x00 ; Enable PortB data pins 02A8 0086 01072 movwf PortB ; 02A9 1283 01073 bcf STATUS,B_RP0 ; Switch to bank 0 02AA 1086 01074 bcf PortB,LCD_rs ; Set LCD for commands (RS) 02AB 1106 01075 bcf PortB,LCD_rw ; Set LCD for write 01076 ; 02AC 300F 01077 movlw 0x0F ; Transfer the first nibble 02AD 0586 01078 andwf PortB,f ; 02AE 082B 01079 movf LCD_char,w ; 02AF 39F0 01080 andlw 0xF0 ; 02B0 0486 01081 iorwf PortB,f ; 02B1 1586 01082 bsf PortB,LCD_e ; Pulse the E line 02B2 0000 01083 nop ; 02B3 1186 01084 bcf PortB,LCD_e ; 01085 ; 02B4 300F 01086 movlw 0x0F ; Transfer the second nibble 02B5 0586 01087 andwf PortB,f ; 02B6 0EAB 01088 swapf LCD_char,f ; 02B7 082B 01089 movf LCD_char,w ; 02B8 39F0 01090 andlw 0xF0 ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 22 LOC OBJECT CODE LINE SOURCE TEXT VALUE 02B9 0486 01091 iorwf PortB,f ; 02BA 1586 01092 bsf PortB,LCD_e ; Pulse the E line 02BB 0000 01093 nop ; 02BC 1186 01094 bcf PortB,LCD_e ; 02BD 0008 01095 return ; 01096 ; 01097 ;******************************************************************************* 01098 ; 01099 ; Send Data to the LCD Subroutine. 01100 ; The data to be sent must in LCD_char before calling the subroutine. 01101 ; 02BE 01102 Data2LCD 02BE 228C 01103 call Busy_Check ; Wait until the LCD is free 02BF 0186 01104 clrf PortB ; Clear PortB outputs 02C0 1683 01105 bsf STATUS,B_RP0 ; Switch to bank 1 02C1 3000 01106 movlw 0x00 ; Set as inputs 02C2 0086 01107 movwf PortB ; 02C3 1283 01108 bcf STATUS,B_RP0 ; Switch to bank 0 02C4 1486 01109 bsf PortB,LCD_rs ; Set RS for data 02C5 1106 01110 bcf PortB,LCD_rw ; Clear RW for write 01111 ; 02C6 300F 01112 movlw 0x0F ; Transfer the first nibble 02C7 0586 01113 andwf PortB,f ; 02C8 082B 01114 movf LCD_char,w ; 02C9 39F0 01115 andlw 0xF0 ; 02CA 0486 01116 iorwf PortB,f ; 02CB 1586 01117 bsf PortB,LCD_e ; Pulse E line 02CC 0000 01118 nop ; 02CD 1186 01119 bcf PortB,LCD_e ; 01120 ; 02CE 300F 01121 movlw 0x0F ; Transfer the second nibble 02CF 0586 01122 andwf PortB,f ; 02D0 0EAB 01123 swapf LCD_char,f ; 02D1 082B 01124 movf LCD_char,w ; 02D2 39F0 01125 andlw 0xF0 ; 02D3 0486 01126 iorwf PortB,f ; 02D4 1586 01127 bsf PortB,LCD_e ; Pulse the E line 02D5 0000 01128 nop ; 02D6 1186 01129 bcf PortB,LCD_e ; 02D7 0008 01130 return ; 01131 ; 01132 ;******************************************************************************* 01133 ; 02D8 01134 WriteEE 02D8 1683 01135 bsf STATUS,B_RP0 ; Switch to bank 1 02D9 1508 01136 bsf EEdata,WREN ; 02DA 3055 01137 movlw 0x55 ; 02DB 0089 01138 movwf EEadr ; 02DC 30AA 01139 movlw 0xAA ; 02DD 0089 01140 movwf EEadr ; 02DE 1488 01141 bsf EEdata,WR ; 02DF 01142 bit_check 02DF 1888 01143 btfsc EEdata,WR ; MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 23 LOC OBJECT CODE LINE SOURCE TEXT VALUE 02E0 2ADF 01144 goto bit_check ; 02E1 1108 01145 bcf EEdata,WREN ; 02E2 1283 01146 bcf STATUS,B_RP0 ; Switch to bank 0 02E3 0A89 01147 incf EEadr,f ; 02E4 0008 01148 return ; 01149 ; 01150 ;******************************************************************************* 01151 ; 02E5 01152 ReadEE 02E5 1683 01153 bsf STATUS,B_RP0 ; Switch to bank 1 02E6 1408 01154 bsf EEdata,RD ; 02E7 1283 01155 bcf STATUS,B_RP0 ; Switch to bank 0 02E8 0A89 01156 incf EEadr,f ; 02E9 0008 01157 return ; 01158 ; 01159 ;******************************************************************************* 01160 ; 01161 ; Delay subroutines. 01162 ; 02EA 01163 Wait255 02EA 30FF 01164 movlw 0xFF ; Set up timer 02EB 00AD 01165 movwf timer1 ; 02EC 2AF8 01166 goto Wait16 ; 02ED 01167 Wait128 02ED 3080 01168 movlw 0x80 ; 02EE 00AD 01169 movwf timer1 ; 02EF 2AF8 01170 goto Wait16 ; 02F0 01171 Wait64 02F0 3040 01172 movlw 0x40 ; 02F1 00AD 01173 movwf timer1 ; 02F2 2AF8 01174 goto Wait16 ; 02F3 01175 Wait32 02F3 3020 01176 movlw 0x20 ; 02F4 00AD 01177 movwf timer1 ; 02F5 2AF8 01178 goto Wait16 ; 02F6 3010 01179 movlw 0x10 ; 02F7 00AD 01180 movwf timer1 ; 02F8 01181 Wait16 02F8 30FF 01182 movlw 0xFF ; 02F9 00AE 01183 movwf timer2 ; 02FA 01184 inner 02FA 0BAE 01185 decfsz timer2,f ; 02FB 2AFA 01186 goto inner ; 02FC 0BAD 01187 decfsz timer1,f ; 02FD 2AF8 01188 goto Wait16 ; 02FE 0008 01189 return ; 01190 ; 01191 ;******************************************************************************* 01192 ; 01193 END MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 24 SYMBOL TABLE LABEL VALUE . 00000007 AD9850 00000015 AD9850_2 00000016 AD9850_3 00000017 AD9850_4 00000018 AD9850_5 00000019 BIN2BCD 00000207 B_C 00000000 B_DC 00000001 B_EEIE 00000006 B_GIE 00000007 B_INTE 00000004 B_INTF 00000001 B_NPD 00000003 B_NTO 00000004 B_RBIE 00000003 B_RBIF 00000000 B_RP0 00000005 B_T0IE 00000005 B_T0IF 00000002 B_Z 00000002 BandTable 00000094 Busy_Check 0000028C Cal_Loop 00000176 Calc_DDS_Word 000001B7 Calibrate 00000158 Cmnd2LCD 000002A4 DDS_clk 00000005 DDS_dat 00000007 DDS_load 00000000 Data2LCD 000002BE EEadr 00000009 EEdata 00000008 FSR 00000004 GetBand 000000B9 INDF 00000000 INTCON 0000000B LCD_char 0000002B LCD_e 00000003 LCD_read 0000002C LCD_rs 00000001 LCD_rw 00000002 Last_dir 00000034 Main 0000005E Next_dir 00000035 PCL 00000002 PCLATH 0000000A PbSwitch 00000003 PollEncoder 0000012E PortA 00000005 PortB 00000006 RD 00000000 ReadEE 000002E5 MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 25 SYMBOL TABLE LABEL VALUE STATUS 00000003 S_copy 00000037 Send_DDS_Word 000001ED ShowFreq 00000237 TRISA 00000005 TRISB 00000006 WR 00000001 WREN 00000002 W_copy 00000036 Wait128 000002ED Wait16 000002F8 Wait255 000002EA Wait32 000002F3 Wait64 000002F0 WriteEE 000002D8 __16F84 00000001 add1 000000D4 add2 000000DB add3 000000E0 add4 00000199 add5 000001A0 add6 000001A5 add7 000001D2 add8 000001D9 add9 000001DE add_step 000000CB adjBCD 0000022A adjust 0000021E band 00000039 bandUp 00000088 bcd 00000010 bcdCount 0000001E bcdTemp 0000001F bcd_2 00000011 bcd_3 00000012 bcd_4 00000013 bcd_5 00000014 bitCount 00000021 bit_check 000002DF break 000001FD bumpstep 0000006D byte2send 00000022 changeBand 0000007C compDone 00000112 continue 0000014F count 00000038 down 00000078 exit1 00000106 exit2 0000012D exit3 00000155 faster 00000190 freq 0000000C freq_2 0000000D MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 26 SYMBOL TABLE LABEL VALUE freq_3 0000000E freq_4 0000000F fset_3 0000001C fstep 0000001A fstep_2 0000001B fstep_4 0000001D goStep 00000072 inner 000002FA isr_entry 00000004 lcd_is_busy 00000295 loop 0000020E multCount 00000020 mult_loop 000001C6 next_bit 000001F3 next_byte 000001EF noAdd 000001E0 noInc 00000138 not_busy 000002A3 osc 00000023 osc_2 00000024 osc_3 00000025 osc_4 00000026 osc_temp 00000027 osc_temp_2 00000028 osc_temp_3 00000029 osc_temp_4 0000002A readEEocs 0000003A read_encoder 00000131 ren_new 00000031 ren_old 00000032 ren_read 00000033 ren_timer 0000002F ren_timer_2 00000030 reset_entry 00000000 send0 000001FA setMax 000000FE setMin 00000127 start 0000000C sub_step 00000107 timer1 0000002D timer2 0000002E up 0000007A up2 00000153 updateOSC 00000182 valid 00000086 write 0000008F MPASM 02.15.06 Intermediate SIG_GEN2.ASM 12-9-1998 10:11:48 PAGE 27 MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : X---XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0140 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0180 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 01C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0200 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0240 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0280 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 02C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX- 2000 : XXXX---X-------- ---------------- ---------------- ---------------- 2100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX All other memory blocks unused. Program Memory Words Used: 764 Program Memory Words Free: 260 Errors : 0 Warnings : 4 reported, 0 suppressed Messages : 0 reported, 0 suppressed