Digital Signal Processing Reference
In-Depth Information
FIGURE 3.14. A 32-bit noise generator diagram.
3. The LSB of the resulting summation is selected. This bit is either a 1 or a 0
and is scaled accordingly to a positive or negative value.
4. The seed value is shifted left by one, and the resulting bit from the previous
step is placed in the LSB position and the process repeated with the new
(shifted by one) seed value.
The 32-bit noise generator diagram is shown in Figure 3.14. Within the asm func-
tion, the seed value is moved from A4 to A1. Shifting this seed value right by 17
places bit 17 in the LSB position, where the addition is meaningful. The resulting
summation is shifted right by 11 to place bit 28 (already shifted by 17) in the LSB
position. This procedure is repeated, adding bits 17, 28, 30, and 31. The LSB, which
is a 1 or a 0, is then placed into A4, and returned to the C calling function, where it
is scaled as either a positive or a negative value, respectively. On each interrupt, this
LSB bit, 1 or 0, represents the noise sample.
Build and run this project as Noisegen_casm . Sampling at 48 kHz, verify that
the noise spectrum is flat, with a bandwidth of approximately 23 kHz. Connect the
output to a speaker to verify the generated noise. Change the scaling values to
±
8000
and verify that the level of the generated noise is reduced.
Set a breakpoint in the asm function and view the value of A4 before it is
returned to the C calling function and verify the noise sequence as 1, 1, 1, 1, 0, 1, 0,
1,1,1,1,0,0,1,1,0,...This noise sequence will repeat after (2 N
-
1) with N as a
32-bit seed.
Example 3.5: Code Detection Using C Calling an
ASM Function ( Code_casm )
This example detects a four-digit code set initially in the main C source program.
Figure 3.15 shows the main C source program code_casm.c that calls the asm
function code_casmfunc.asm , shown in Figure 3.16 . The code is set with code1 ,
Search WWH ::




Custom Search