Issue
130 May 2001
DDS-GENPart
2: The Generator
Start Direct Digital Synthesis?
The AD9852 monster chip Hardware
Prototype Construction On The Software Side Design Methodology Whats Next? Sources & PDF
On The
Software Side
The complete
listing of DDS-GEN software is on the Circuit Cellar web
site. Like the I2C-MMI software, this code is mainly written
in C, thanks again to the good freeware SDCC-optimizing
cross-compiler. Some in-line assembler code is used, however,
mainly for interrupt handling routines and code-space
optimization.
And, as always,
I check the Internet to see if what I need is already
out there. I used, without modification, the C code I2C
handler library written by Sandeep Dutta (thanks, Sandeep!)
and interrupt-handling code from the SDCC accompanying
files. [3]
The dynamic
structure of the DDS-GEN embedded software is classic
(field-proven) and interrupt-driven (see Figure 7). After
initializations, the main program manages the user interface
and stores all parameters that need to be loaded into
the DDS chip in a shared RAM buffer.
|

(Click
here to enlarge)
|
Figure
7A main program waits for a user event, manages
menus, and updates a parameter array in shared memory.
And, an interrupt routine refreshes the DDS chip registers
and manages modulation tasks. |
The interrupt
routine, executed each time the DDS chip asks for new
values with its "I/O update" signal, executes
an A/D conversion of the external modulation signal. And
if a modulation is requested, it recalculates the frequency,
amplitude, and phase on the fly. It then uploads the modified
parameters into the DDS chip one block at a time to limit
interrupt latency.
In order to
define a precise interrupt frequency, the DDS chip is
programmed in Internal Update mode. In Internal Update
mode, the update of its internal registers is automatic
and executed at a preprogrammed refresh rate. The I/O
update signal is an output that generates an interrupt
on the microcontroller.
The shared RAM
buffer maps exactly the AD9852 register set. This array
is then segmented in blocks, corresponding to the AD9852
serial transfer blocks; each block is the set of parameters
that should be downloaded in one individual operation.
Every time a parameter change is needed, the relevant
registers are updated by the main program in the shadow
array and a flag is sent to indicate that the corresponding
block must be downloaded to the DDS chip during the next
interrupt.
DDS-GEN menus
are managed by a generic software menu engine, which is
based on a table of menu targets stored in ROM. Each menu
target corresponds to a specific LCD mask, and defines
the static text to be displayed and the numerical format
of the value to be edited (number of digits before and
after the decimal). Each menu target also defines a pointer
to a pre-processing procedure (func_enterxxx). This procedure
is usually in charge of converting the value to be edited
from internal to human form.
And, lastly,
it defines a pointer to a post-processing procedure (func_selectxxx).
This procedure usually controls conversion of the value
just edited from human to internal form and updates the
shadow DDS parameter array in RAM.
The main menu
engine is straightforward. Thanks to the onboard intelligence
of the I2C-MMI peripheral module, every value displayed
can be modified with the keyboard, rotary encoder, or
from a host computer connected to the serial port without
specific code in the application software.
© Circuit Cellar,
The Magazine for Computer Applications. Reprinted with
permission. For subscription information call (860) 875-2199,
email subscribe@circuitcellar.com or on our web site at
www.circuitcellar.com.