📄 randtest.c
字号:
//
// Project: Experiment 3.6.6.4 Real Time Signal Generation - Chapter 3
// File name: randTest.c
//
// Description: This function is a random number generator for C5510 DSK
// This experiment uses the C5x assembly routine randNumber()
//
// For the book "Real Time Digital Signal Processing:
// Implementation and Application, 2nd Ed"
// By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
// Publisher: John Wiley and Sons, Ltd
//
// Tools used: CCS v.2.12.07
// TMS320VC5510 DSK Rev-C
//
#include "randGencfg.h"
#include "dsk5510.h"
#include "dsk5510_aic23.h"
// Codec configuration settings
DSK5510_AIC23_Config config = { \
0x0017, /* 0 DSK5510_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017, /* 1 DSK5510_AIC23_RIGHTINVOL Right line input channel volume */\
0x01f9, /* 2 DSK5510_AIC23_LEFTHPVOL Left channel headphone volume */ \
0x01f9, /* 3 DSK5510_AIC23_RIGHTHPVOL Right channel headphone volume */ \
0x0011, /* 4 DSK5510_AIC23_ANAPATH Analog audio path control */ \
0x0000, /* 5 DSK5510_AIC23_DIGPATH Digital audio path control */ \
0x0000, /* 6 DSK5510_AIC23_POWERDOWN Power down control */ \
0x0043, /* 7 DSK5510_AIC23_DIGIF Digital audio interface format */ \
0x008D, /* 8 DSK5510_AIC23_SAMPLERATE Sample rate control */ \
0x0001 /* 9 DSK5510_AIC23_DIGACT Digital interface activation */ \
};
// Funciton prototypes
void randGen(unsigned short seconds, unsigned short sampleRate);
extern short randNumber(void);
extern void initRand(long seed);
// Glabel veriables
DSK5510_AIC23_CodecHandle hCodec;
void main()
{
// Initialize the board support library, must be called first
DSK5510_init();
// Start the codec
hCodec = DSK5510_AIC23_openCodec(0, &config);
// Initialization
initRand(12357);
// Generate 5 seconds random number
randGen(5, 8000);
// Close the codec
DSK5510_AIC23_closeCodec(hCodec);
}
void randGen(unsigned short seconds, unsigned short sampleRate)
{
unsigned short i,j;
short sample;
for (i = 0; i < seconds; i++)
{
for (j = 0; j < sampleRate; j++)
{
sample = randNumber();
// Write a sample to the left output channel
while (!DSK5510_AIC23_write16(hCodec, sample));
// Write a sample to the right output channel
while (!DSK5510_AIC23_write16(hCodec, sample));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -