Programming the 16F688
Download this zip file
SI4133.ZIP
from Silicon Labs.
Unzip
the file and run SETUP.EXE (429 kb) It is nice, but not necessary
to install the port95NT.exe. In this synthesizer we are mainly
interested in using the register function of the program.
The
SI4133 programmer shows all the registers for this family of parts, but here,
we are only concerned with the IF synthesizer. So RF1 and RF2 (PDRB)
are not selected and PDIB is selected. Later you will see that the non
existent RF registers are loaded with zeroes. For now all we want to
get is the register values for the IF synthesizer.
Select SiLabs and select "register
values", this should have a check mark if selected and a box appears at
the left with register values for nine registers (0 - 8)
Fill in
the reference frequency, maybe 10.000 MHz. Fill in the R divider, 10.
Fill in the VCO frequency, 578. Leave the Phase detector set to Auto.
For
this example the VCO frequency is the output frequency, so the IF
divider is " f ". IF divider can also be f/2 f/4 or
f/8. Set the Auxiliary output control to "lock detect
LDETB". It is important that all entries are selected correctly.
It is easy to overlook the IF divider.
The
SI4112 uses registers 0, 1, 2, 5, and 8. For these registers we read
from the chart 3004, 4, 2, 242 and A. These are values in HEX.
skip down to read more.....
In
the source code the only editing that is needed is in the frequency
section. Due to the way registers are handled in the PIC there is
always a leading zero in the first PIC register, register H,and each
synthesizer register is identified by the last digit, shown in blue.
The SI4112 uses registers 0, 1, 2, 5, and 8. For these registers we
read from the chart 3004, 4, 2, 242 and A, as noted below in red. These are values in HEX. Synthesizer registers 3,4, 6 and 7
can have the default values, as we will not address any data to
these registers.
reg value
0
3004
1
4
2
2
3 1F40
4 1770
5
242
6 32
7 32
8
A
Below is a copy of a section of the source code for the 9 registers, 0 - 8. Register numbers are in
blue and
the values, taken from above, are in
red.
freq1
; 578 mhz
; load registers reg_H reg_M and reg_L
; Load the main register (
0)
;
movlw 0x0
3
;
movwf reg_H
;
movlw 0x
00
;
movwf reg_M
;
movlw 0x
40
;
movwf reg_L
;
CALL sendreg
; Send data to REGISTERS
;So the zero after
the 4 identifies this data as going to register 0 in the synthesizer.
The rest of the registers are filled in, in similar fashion.
; Load the phase det register (
1)
; MSB first
;
movlw 0x00
;
movwf reg_H
;
movlw 0x00
;
movwf reg_M
;
movlw 0x
41
;
movwf reg_L
;
CALL sendreg
; Send data to REGISTERS
;
; Load the power down register (
2)
; MSB first
;
movlw 0x00
;
movwf reg_H
;
movlw 0x00
;
movwf reg_M
;
movlw 0x
22
;
movwf reg_L
;
CALL sendreg
; Send data to REGISTERS
;
; Load the IF N register (
5)
;
movlw 0x00
;
movwf reg_H
;
movlw 0x
24
;
movwf reg_M
;
movlw 0x
25
;
movwf reg_L
;
CALL sendreg
; Send data to REGISTERS
;
; Load the IF R register (
8)
; MSB first
;
movlw 0x00
;
movwf reg_H
;
movlw 0x00
;
movwf reg_M
;
movlw 0x
A8
;
movwf reg_L
;
CALL sendreg
; Send data to REGISTERS
;
CALL BLINK1
RETURN ;
That's the short description, hopefully useful.
There
are 3 PIC registers, H M and L, needed to hold the data for each synthesizer
register. reg_H always has the first byte as 0.
reg_L always has the last byte as the synthesizer register number, shown in blue above.
Synthesizer registers
may be written individually if the user recognizes that only one
register changes. This puts the burden on the programmer to get this right.
As an example, to change from 578 Mhz to 576 MHz, only register 5
changes. We could make a frequency selection in the source code that
looks this....
freq2
; 576 mhz
; load registers reg_H reg_M and reg_L
Load the IF N register (5)
;
movlw 0x00
;
movwf reg_H
;
movlw 0x
24
;
movwf reg_M
;
movlw 0x
05
;
movwf reg_L
;
CALL sendreg
; Send data to REGISTERS
This
only works if registers 0,1,2 and 8 have been previously loaded with
the correct values. For very specific tasks the source code can be
greatly simplified by loading the registers immediately on start up,
then loading register 5 to set the frequency according to the
switch selection. There after, only register 5 needs to be written.
The
three PIC, H,M and L registers load in 6 uS, and the data in
the three registers, H,M and L, is loaded into the synthesizer register in 304
uS., for a total of 310 uS. So every synthesizer register that does not
need to be written will shave off 310 uS. The potential time
saving by not writing the the registers that don't change is 1.2 mS.
There is
lots of memory in the 16F688, and even more time could be saved at the
expense of using more memory. This code was written as a simple way to
get the synthesizer on frequency. The three registers, reg_H, reg_M and
reg_L are used in every operation and could be replaced by dedicated
registers that hold the data for each synthesizer registers. So
you might have 0reg_H, 0reg_M 0reg_L, 1reg_H, 1reg_M, 1reg_L
etc through 8. Another thought is to have 5 different sendreg routines,
but instead of testing each bit in the register, just call the
appropriate routine to send 0 or 1.
Lots of ways that will work !