June
2000, Issue 107
Low-Cost
Software
Bell-202
Modem
APPLICATION
DEVELOPMENT
Adding
functions to an SX28AC-based design is as simple as
going to a web site and downloading the desired virtual
peripherals. New software development and programming
are equally painless.
The
chip is programmed over its oscillator pins (26, 27)
using the SX-Key development system (a 0.5² × 1.5² module
that connects at one end to a PC by a standard DE-9
connector and at the other end to the system board by
a four-pin header interface connector). The SX-Key software,
which includes an editor, programmer, and debugger,
can be installed on a PC and run under Windows.
With
the SX-Key software loaded and the PC connected to the
circuit through the hardware module, software development
begins immediately. The first screen is a device setup
window.
It
lets you set parameters such as the number of pins and
on-chip memory size of the SX-series MCU youre
using, the clock source (an external frequency generator
in this design, although a range of internal oscillator
frequencies can also be selected), and additional options
like stack extensions and an on-chip watchdog timer.
A configuration window lets you select the desired communication
port and specify the erase and program times for the
flash program memory.
With
the chip parameters established, an Edit window lets
you write the program. All timing-dependent operations
must be run within an interrupt service routine, so
the code needs to be written using an interrupt indicator.
An
on-chip hardware timer produces a real-time clock/counter
(RTCC) signal that generates interrupts. The RTCC can
be set to establish how many clock cycles occur before
an interrupt must be serviced.
The
general program flow is:
(load RTCC countdown)
run application code
RTCC times out, issues interrupt
interrupt service routine
run peripheral routine
load RTCC countdown
RETI (return from interrupt)
run application code
|
Listing
1 shows the initialization part of the program for
this modem design.
After
resetting the SX chip, the I/O ports and the default
values for some software variables must be initialized.
The final line of code in the reset entry code typically
loads the Option register with the proper value to enable
RTCC clock rate and interrupts.
In
this design, the contents of the RTCC are incremented
each clock cycle. If the RTCC overflows, an interrupt
request follows. The RTCC overflow interrupt is essential
to the virtual-peripheral concept, as it provides a
jitter-free time base that is used as the time slice
for the peripherals. Much like an RTOS, this master
clock can then increment other clocks specific to each
task.
The
completed program and the virtual peripherals are loaded
into the MCUs on-chip program memory through the
SX-Key module. A Debug window (see Photo 1) displays
the result of programming the chip and provides interactive
debugging options.
The
left column shows the contents of registers 000F
of the selected RAM bank in hex and binary numbers.
The contents of registers 101F of the remaining
RAM banks are displayed on the right side.
In
the middle of the Debug window, the contents of the
M and W registers are shown as well as interrupt and
skip flags. Beneath that is listed the address, opcode,
and assembler mnemonic of the selected part of the program
memory.
Buttons
for emulation functions are arranged across the window
bottom:
stepexecutes one instruction
walkexecutes multiple instructions, one
at a time
runexecutes instructions at full speed
stophalts execution of a walk or run
operation
resetresets the MCU
exitcloses the Debug window
To
debug the program, just reset the contents of any of
the registers. All the changed registers are marked
with red during debugging so you dont lose the
track of what youre doing.
When
youre satisfied that youve corrected the
bugs, reprogram the chip. Because youre working
with flash memory, you can go through as many iterations
as you want to get it right.
AT
LAST, A CHOICE
For
about $7, I was able to design a compact fully functional
embedded modem that meets the needs of all kinds of
applications. It was possible because designers have
a choice not only of modems, but also of every imaginable
type of embedded system.
Stephen
Holland is a senior applications engineer at Scenix
Semiconductor. Before joining Scenix in early 1998,
he worked for over six years in the electronics and
computer industries in Canada and Hong Kong. You may
reach him at stephen.holland@scenix.com.