September
1998, Issue 98
PIC'Spectrum
Audio
Spectrum Analyzer
DEVELOPMENT
AND DEBUG
Debugging
a signal-processing embedded application isnt
easy. And, I dont have access to an adequate ICE.
Since it might be useful for similar projects, let me
briefly explain my methodology (which must not be too
bad: PICSpectrum actually works!).
After
some timing calculations to ensure the feasibility of
the concept, I started with a prototyping phase on a
PC using a PC sound board as input. I used floating-point
calculations, with everything in C (see Listing
1). I then translated the software to use exclusively
integer numbers and debugged it.
The
third step was to develop a fixed-point library (still
on the PC) that prefigures the future PIC-based fixed-point
library. I also modified the FFT code to do all calculations
exclusively through this library. It was quite easy
to write this fixed-point library in PIC assembler,
debug it on Microchips simulator, and translate
the FFT routine from C to assembler.
Using
the simulator is useful for numerical-calculation software.
In fact, it was possible to open two windows on my PC,
the first being a standard PC debugger with my C-code
FFT, and the second the PIC simulator with the manually
translated assembler code. Single stepping between the
two codes with a test signal as an input helped me quickly
find the more tricky bugs.
When
the signal-processing part was completed and debugged,
I wrote the real-time part (signal acquisition and video
generation) and debugged it as much as I could on the
simulator.
This
phase was helpful for correcting timing issues related
to video synchronization. For example, with a breakpoint
set on each access to the horizontal synchronization
pin, its easy to verify if the timings on this
pin meet the VGA specification.
I
waited until this phase was successful before cabling
the prototype. The first EPROM I burned didnt
work 100%, but I got a working video image and something
resembling a spectrum display.
Thanks
to the in-circuit programming and some debug pins, the
software was working soon. In fact, 90% of the bugs
found in this last step were related to banking register
issues, which are tough to simulate because hardware
ports are involved.