|
装入并运行应用程序 1. 启动CCS后,打开位于C:\ti\tutorial\evm6201\sinewave下的工程文件sinewave.pjt,观察CCS的工程视图窗口,发现Projects项下的sinewave.pjt已经被加入其中。打开Source子项,可见本工程只有一个源文件sine.c。用鼠标双击,会打开一个源文件窗口,并将sine.c装入其中。 2. 选择菜单命令“Project”|“Build”,或者单击工具栏上的Incremental Build按钮,完成编译链接,得到.out文件。注意输出窗口中应该显示没有错误和警告。 3. 选择“File”|“Load Program”命令,加载程序,然后在“Load Program”对话框中选择打开C:\ti\tutorial\evm6201\sinewave\debug目录中的sinewave.out文件。程序加载后会自动打开一个反汇编窗口,此时黄色小箭头指向的是c_init00,这是C语言引导代码的入口。 4. 选择“Debug”|“Go Main”命令,此时会自动打开main.c源文件窗口,并停在main()函数入口处。从这里开始就可以调试用户程序了。 sine.h代码 // **************************************************************** // Description: This application uses ProbePoints to obtain input // (a sine wave). It then takes this signal, and applies a gain // factor to it. // Filename: Sine.h // ****************************************************************
// define boolean TRUE #ifndef TRUE #define TRUE 1 #endif
// buffer constants #define BUFFSIZE 0x64 #define INITIALGAIN 5
// IO buffer structure typedef struct IOBuffer { int input[BUFFSIZE]; int output[BUFFSIZE]; } BufferContents;
sine.c代码
// **************************************************************** // Description: This application uses Probe Points to obtain input // (a sine wave). It then takes this signal, and applies a gain // factor to it. // Filename: Sine.c // ****************************************************************
#include <stdio.h> #include "sine.h"
// gain control variable int gain = INITIALGAIN;
// declare and initalize a IO buffer BufferContents currentBuffer;
// Define some functions static void processing(); // process the input and generate output static void dataIO(); // dummy function to be used with ProbePoint
void main() { puts("SineWave example started.\n");
while(TRUE) // loop forever { /* Read input data using a probe-point connected to a host file. Write output data to a graph connected through a probe-point. */ dataIO();
/* Apply the gain to the input to obtain the output */ processing(); } }
/* * FUNCTION: Apply signal processing transform to input signal * to generate output signal * PARAMETERS: BufferContents struct containing input/output arrays of size BUFFSIZE * RETURN VALUE: none. */ static void processing() { int size = BUFFSIZE;
while(size--){ currentBuffer.output[size] = currentBuffer.input[size] * gain; // apply gain to input } }
/* * FUNCTION: Read input signal and write processed output signal * using ProbePoints * PARAMETERS: none. * RETURN VALUE: none. */ static void dataIO() { /* do data I/O */ return; }
|