当前位置:文档之家› DSP实验报告+心得体会

DSP实验报告+心得体会

龙岩学院

实验报告

班级07电本(1)班学号2007050344 姓名杨宝辉同组人独立

实验日期2010-5-18 室温大气压成绩

基础实验

一、实验目的

1. 掌握CCS实验环境的使用;

2. 掌握用C语言编写DSP程序的方法。

二、实验设备

1. 一台装有CCS软件的计算机;

2. DSP实验箱的TMS320F2812主控板;

3. DSP硬件仿真器。

三、实验原理

浮点数的表达和计算是进行数字信号处理的基本知识;产生正弦信号是数字信号处理中经常用到的运算;C语言是现代数字信号处理表达的基础语言和通用语言。写实现程序时需要注意两点:(1)浮点数的范围及存储格式;(2)DSP的C语言与ANSI C语言的区别。

四、实验步骤

1.打开CCS 并熟悉其界面;

2.在CCS环境中打开本实验的工程(Example_base.pjt),编译并重建.out 输出文件,然后通过仿真器把执行代码下载到DSP芯片中;

3.把X0 , Y0 和Z0添加到Watch窗口中作为观察对象(选中变量名,单击鼠标右键,在弹出菜单中选择“Add Watch Window”命令);

4.选择view->graph->time/frequency…。设置对话框中的参数: 其中“Start Address”

设为“sin_value”,“Acquisition buffer size”和“Display Data size”都设为“100”,并且把“DSP Data Type”设为“32-bit floating point”,

设置好后观察信号序列的波形(sin函数,如图);

5.单击运行;

6.观察三个变量从初始化到运算结束整个过程中的变化;观察正弦波形从初始化到运算结束整个过程中的变化;

7.修改输入序列的长度或初始值,重复上述过程。

五、实验心得体会

通过本次实验,加深了我对DSP的认识,使我对DSP实验的操作有了更进一步的理解。基本掌握了CCS实验环境的使用,并能够使用C语言进行简单的DSP程序设计。

从软件的安装到使用软件进行程序设计与仿真,锻炼了自己的动手能力,也遇到了不少的坎坷,例如芯片的选择,不能因为麻烦而省略该步骤,否则将会运行出错。

附录实验程序:

#include "math.h"

#include "stdio.h"

#define N 100

#define pi 3.14159

float sin_value[100];

float X0,Y0,Z0;

void main(void)

{

int i;

for(i=0;i

sin_value[i]=0;

X0=0.5; /* 0.100 0000 0000 0000 */

Y0=0.5; /* 0.100 0000 0000 0000 */

Z0=X0*Y0; /* 00.01 0000 0000 0000 0000 0000 0000 0000 */

for(i=0;i

sin_value[i]=100*(sin(2*pi*i/N));

}

龙岩学院

实验报告

班级07电本(1)班学号2007050344姓名杨宝辉同组人独立

实验日期2010-5-20 室温大气压成绩

数码管控制实验

一、实验目的

1.熟悉2812的指令系统;

2. 熟悉74HC573的使用方法。

3. 熟悉DSP的IO操作使用方法。

二、实验设备

1. 一台装有CCS2000软件的计算机;

2. 插上2812主控板的DSP实验箱;

3. DSP硬件仿真器。

三、实验原理

此模块由数码管和四个锁存器组成。数码管为共阴极型的。数据由2812模块的低八位输入,锁存器的控制信号由2812模块输出,但经由CPLD模块译码后再控制对应的八个

四、实验步骤

1. 把2812模块小板插到大板上;

2.在CCS2000环境中打开本实验的工程编译Example_7segled.prj,生成输出文件,通过仿真器把执行代码下载到DSP芯片;

3.运行程序;数码管会显示1~8的数字。

4.参考源代码自行修改程序改变显示样式。

五、实验心得体会

通过本次实验中,基本掌握了2812的指令系统的特点,并能够了解并熟悉74HC573的使用方法,进一步加深了对DSP的认识。同时,通过实验操作DSP的IO操作使用方法,对于DSP的IO操作可以熟悉的运用,学到更多的知识。

程序见附录:

#include "include/DSP281x_Device.h" // DSP281x Headerfile Include File

#include "include/DSP281x_Examples.h" // DSP281x Examples Include File

// Prototype statements for functions found within this file.

void delay_loop(void);

void Gpio_select(void);

// Global variable for this example

short codetab[17]=

{0x4020,0x6cc0,0x5800,0x4840,0x6440,0xC040,0xC000,0x4cc0,

0x4000,0x4040,0x4400,0xE000,0xD080,0xE800,0xD000,0xD400,0xffff};

main()

{

short i;

// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

// This example function is found in the DSP281x_SysCtrl.c file.

InitSysCtrl();

// Specific clock setting for this example:

EALLOW;

EDIS;

// Step 2. Initalize GPIO:

// This example function is found in the DSP281x_Gpio.c file and // illustrates how to set the GPIO to it's default state.

// InitGpio(); // Skipped for this example

// For this example use the following configuration:

Gpio_select();

// Step 3. Clear all interrupts and initialize PIE vector table:

// Disable CPU interrupts

DINT;

// Initialize the PIE control registers to their default state.

// The default state is all PIE interrupts disabled and flags

// are cleared.

// This function is found in the DSP281x_PieCtrl.c file.

InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000;

IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR).

// This will populate the entire table, even if the interrupt

// is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP281x_DefaultIsr.c.

// This function is found in DSP281x_PieVect.c.

InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:

// This function is found in DSP281x_InitPeripherals.c

// InitPeripherals(); // Not required for this example

InitXintf(); // For this example, init the Xintf

// Step 5. User specific code, enable interrupts:

GpioDataRegs.GPADA T.all=0;

Reg01=0x00;

GpioDataRegs.GPADA T.all=0;

Reg02=0x00;

GpioDataRegs.GPADA T.all=0;

Reg03=0x00;

GpioDataRegs.GPADA T.all=0;

Reg04=0x00;

while(1)

{

for(i=0;i<17;i++)

{

GpioDataRegs.GPADA T.all =~codetab[i];

Reg01=0x00;

delay_loop();

}

for(i=0;i<17;i++)

{

GpioDataRegs.GPADA T.all =~codetab[i];

Reg02=0x00;

delay_loop();

}

for(i=0;i<17;i++)

{

GpioDataRegs.GPADA T.all =~codetab[i];

Reg03=0x00;

delay_loop();

}

for(i=0;i<17;i++)

{

GpioDataRegs.GPADA T.all =~codetab[i];

Reg04=0x00;

delay_loop();

}

}

}

void delay_loop()

{

short i,j;

for (i = 0; i < 32767; i++)

{for (j = 0; j < 10; j++);}

}

void Gpio_select(void)

{ Uint16 var1;

Uint16 var2;

Uint16 var3;

var1= 0x0000; // sets GPIO Muxs as I/Os

var2= 0xFFFF; // sets GPIO DIR as outputs

var3= 0x0000; // sets the Input qualifier values

EALLOW;

GpioMuxRegs.GPAMUX.all=var1;

GpioMuxRegs.GPBMUX.all=var1;

GpioMuxRegs.GPDMUX.all=var1;

GpioMuxRegs.GPFMUX.all=var1;

GpioMuxRegs.GPEMUX.all=var1;

GpioMuxRegs.GPGMUX.all=var1;

GpioMuxRegs.GPADIR.all=var2; // GPIO PORTs as output

GpioMuxRegs.GPBDIR.all=var2; // GPIO DIR select GPIOs as output GpioMuxRegs.GPDDIR.all=var2;

GpioMuxRegs.GPEDIR.all=var2;

GpioMuxRegs.GPFDIR.all=var2;

GpioMuxRegs.GPGDIR.all=var2;

GpioMuxRegs.GPAQUAL.all=var3; // Set GPIO input qualifier values GpioMuxRegs.GPBQUAL.all=var3;

GpioMuxRegs.GPDQUAL.all=var3;

GpioMuxRegs.GPEQUAL.all=var3;

EDIS;

}

// No more.

龙岩学院

实验报告

班级07电本(1)班学号2007050344 姓名杨宝辉同组人独立

实验日期2010-5-25 室温大气压成绩

交通灯控制实验

一、实验目的

1. 熟悉2812的指令系统;

2. 熟悉74HC573的使用方法。

3. 熟悉DSP的IO操作使用方法。

二、实验设备

1. 一台装有CCS2000软件的计算机;

2. 插上2812主控板的DSP实验箱;

3. DSP硬件仿真器。

三、实验原理

此模块由发光二极管和一个锁存器组成。

数据由2812模块的低八位输入,锁存器的控制信号由2812模块输出,但经由CPLD 模块译码后再控制锁存器。

四、实验步骤

1.把2812模块小板插到大板上;

2.在CCS2000环境中打开本实验的工程编译Example_crossled.prj,生成输出文件,

通过仿真器把执行代码下载到DSP芯片;

3.运行程序,发光二极管按交通灯方式点亮熄灭。

4.参考源代码,自行修改程序,实现不同的交通灯控制方式。

五、实验心得体会

通过次实验中,使我掌握了2812的指令系统和74HC573的使用方法。同时,使我掌握了DSP的IO操作使用方法。

实验程序见附录:

附录:

#include "include/DSP281x_Device.h" // DSP281x Headerfile Include File

#include "include/DSP281x_Examples.h" // DSP281x Examples Include File

// Prototype statements for functions found within this file.

void delay_loop(void);

void Gpio_select(void);

// Global variable for this example

main()

{

// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

// This example function is found in the DSP281x_SysCtrl.c file.

InitSysCtrl();

// Specific clock setting for this example:

EALLOW;

EDIS;

// Step 2. Initalize GPIO:

// This example function is found in the DSP281x_Gpio.c file and

// illustrates how to set the GPIO to it's default state.

// InitGpio(); // Skipped for this example

// For this example use the following configuration:

Gpio_select();

// Step 3. Clear all interrupts and initialize PIE vector table:

// Disable CPU interrupts

DINT;

// Initialize the PIE control registers to their default state.

// The default state is all PIE interrupts disabled and flags

// are cleared.

// This function is found in the DSP281x_PieCtrl.c file.

InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000;

IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR).

// This will populate the entire table, even if the interrupt

// is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP281x_DefaultIsr.c.

// This function is found in DSP281x_PieVect.c.

InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:

// This function is found in DSP281x_InitPeripherals.c

// InitPeripherals(); // Not required for this example

InitXintf(); // For this example, init the Xintf

// Step 5. User specific code, enable interrupts:

while(1)

{

GpioDataRegs.GPADA T.all =0xdc80;

Reg00=0x00;

delay_loop();

GpioDataRegs.GPADA T.all =0xec40;

Reg00=0x00;

delay_loop();

GpioDataRegs.GPADA T.all =0xf0c0;

Reg00=0x00;

delay_loop();

GpioDataRegs.GPADA T.all =0xec40;

Reg00=0x00;

delay_loop();

}

}

void delay_loop()

{

short i,j;

for (i = 0; i < 32767; i++)

{for (j = 0; j < 50; j++);}

}

void Gpio_select(void)

{

Uint16 var1;

Uint16 var2;

Uint16 var3;

var1= 0x0000; // sets GPIO Muxs as I/Os

var2= 0xFFFF; // sets GPIO DIR as outputs

var3= 0x0000; // sets the Input qualifier values EALLOW;

GpioMuxRegs.GPAMUX.all=var1;

GpioMuxRegs.GPBMUX.all=var1;

GpioMuxRegs.GPDMUX.all=var1;

GpioMuxRegs.GPFMUX.all=var1;

GpioMuxRegs.GPEMUX.all=var1;

GpioMuxRegs.GPGMUX.all=var1;

GpioMuxRegs.GPADIR.all=var2; // GPIO PORTs as output

GpioMuxRegs.GPBDIR.all=var2; // GPIO DIR select GPIOs as output

GpioMuxRegs.GPDDIR.all=var2;

GpioMuxRegs.GPEDIR.all=var2;

GpioMuxRegs.GPFDIR.all=var2;

GpioMuxRegs.GPGDIR.all=var2;

GpioMuxRegs.GPAQUAL.all=var3; // Set GPIO input qualifier values

GpioMuxRegs.GPBQUAL.all=var3;

GpioMuxRegs.GPDQUAL.all=var3;

GpioMuxRegs.GPEQUAL.all=var3;

EDIS;

}

//================================================================ ===========

// No more.

//================================================================ ===========

龙岩学院

实验报告

班级07电本(1)班学号2007050344 姓名杨宝辉同组人独立

实验日期2010-05-27 室温大气压成绩

步进电机控制实验

一、实验目的

1.掌握2812通用IO口的使用方法;

2.掌握2812对步进电机的控制。

二、实验设备

1. 一台装有CCS软件的计算机;

2. DSP实验箱(插上电机模块);

3. DSP硬件仿真器;

4. 示波器。

三、实验原理

步进电机工作原理,给步进脉冲电机就转,不给脉冲电机就不转,步进脉冲的频率越高,步进控制电机就转的越快;改变各相的通电方式可以改变电机的运行方式;改变通电顺序可以控制步进电机的运行方式;改变通电顺序可以控制步进电机的正反转。

步进电机的控制问题可以总结为两点:

1.产生工作方式需要的时序脉冲;

2.控制步进电机的速度使它始终遵循加速-匀速-减速的规律工作。

对于I/O口有二类寄存器:

1.控制寄存器和数据方向寄存器,使用方法如下:首先确定引脚的功能,即IO控制器寄存器,为1表示引脚功能是原模块的功能,否则为IO功能。

2.如果引脚被配置为IO功能,就需要确定它的方向:输入还是输出,。为1表示是输出引脚,否则是输入引脚。对于IO功能的输入或输出是通过读写相应的数据方向寄存器来实现。输入引脚对应读操作;输出引脚对应写操作。

四、实验步骤

1.连接好DSP开发系统;

2.本实验工程文件(Example_stepmotor.pjt),编译,下载程序到DSP;

运行程序,用观察步进电机运行方向和速度的变化;

五、实验心得体会

通过本次实验对于2812通用的IO口进一步熟悉实验,使我基本掌握了2812通用的IO 口的使用方法,加深了对IO口的认识。本次实验的主要目的是通过2812对步进机的的控制,开始对于程序的设计没有头绪,通过查阅步进机控制的原理,结合有关资料才正式设计出程序,基本掌握了2812对步进机的控制,也更加熟悉了对DSP程序的设计,受益匪浅。

程序:

#include "include/DSP281x_Device.h" // DSP281x Headerfile Include File

#include "include/DSP281x_Examples.h" // DSP281x Examples Include File

// Prototype statements for functions found within this file.

void delay_loop(void);

void Gpio_select(void);

// Global variable for this example

short codetab[17]=

{0x0001,0x0002,0x0004,0x0008,0x0008,0x0004,0x0002,0x0001,

0x0001,0x0002,0x0004,0x0008,0x0001,0x0002,0x0004,0x0008,0x0000};

main()

{ short i,j;

// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

// This example function is found in the DSP281x_SysCtrl.c file.

InitSysCtrl();

// Specific clock setting for this example:

EALLOW;

EDIS;

// Step 2. Initalize GPIO:

// This example function is found in the DSP281x_Gpio.c file and // illustrates how to set the GPIO to it's default state.

// InitGpio(); // Skipped for this example

// For this example use the following configuration:

Gpio_select();

// Step 3. Clear all interrupts and initialize PIE vector table:

// Disable CPU interrupts

DINT;

// Initialize the PIE control registers to their default state.

// The default state is all PIE interrupts disabled and flags

// are cleared.

// This function is found in the DSP281x_PieCtrl.c file.

InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000;

IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR).

// This will populate the entire table, even if the interrupt

// is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP281x_DefaultIsr.c.

// This function is found in DSP281x_PieVect.c.

InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:

// This function is found in DSP281x_InitPeripherals.c

// InitPeripherals(); // Not required for this example

InitXintf(); // For this example, init the Xintf

// Step 5. User specific code, enable interrupts: GpioDataRegs.GPADA T.all=0;

Reg06=0x00;

while(1)

{

for(j=0;j<400;j++)

{

for(i=0;i<4;i++)

{

GpioDataRegs.GPADA T.all =codetab[i];

Reg06=0x00;

delay_loop();

}

}

for(j=0;j<400;j++)

{

for(i=4;i<8;i++)

{

GpioDataRegs.GPADA T.all =codetab[i];

Reg06=0x00;

delay_loop();

}

}

}

}

void delay_loop()

{

short i,j;

for (i = 0; i < 1000; i++)

{for (j = 0; j < 10; j++);}

}

void Gpio_select(void)

{

Uint16 var1;

Uint16 var2;

Uint16 var3;

var1= 0x0000; // sets GPIO Muxs as I/Os

var2= 0xFFFF; // sets GPIO DIR as outputs

var3= 0x0000; // sets the Input qualifier values

EALLOW;

GpioMuxRegs.GPAMUX.all=var1;

GpioMuxRegs.GPBMUX.all=var1;

GpioMuxRegs.GPDMUX.all=var1;

GpioMuxRegs.GPFMUX.all=var1;

GpioMuxRegs.GPEMUX.all=var1;

GpioMuxRegs.GPGMUX.all=var1;

GpioMuxRegs.GPADIR.all=var2; // GPIO PORTs as output

GpioMuxRegs.GPBDIR.all=var2; // GPIO DIR select GPIOs as output GpioMuxRegs.GPDDIR.all=var2;

GpioMuxRegs.GPEDIR.all=var2;

GpioMuxRegs.GPFDIR.all=var2;

GpioMuxRegs.GPGDIR.all=var2;

GpioMuxRegs.GPAQUAL.all=var3; // Set GPIO input qualifier values

GpioMuxRegs.GPBQUAL.all=var3;

GpioMuxRegs.GPDQUAL.all=var3;

GpioMuxRegs.GPEQUAL.all=var3;

EDIS;

}

//============================================================== =============

// No more.

//============================================================== =============

龙岩学院

实验报告

班级07电本(1)班学号2007050344 姓名杨宝辉同组人独立实验日期2010-6-1 室温大气压成绩

直流电机控制实验

一、实验目的

1.要求学生掌握2812 PWM的使用方法;

2.掌握2812对直流电机的控制。

二、实验设备

1. 一台装有CCS软件的计算机;

2. DSP实验箱;

3. DSP硬件仿真器;

4. 示波器。

三、实验原理

电机模块的原理图如下

四、实验步骤

3.连接好DSP开发系统;

4.本实验工程文件(Example_dcmotor.pjt),编译,下载程序到DSP;

5.运行程序,用观察直流电机运行方向和速度的变化;

五、实验心得体会

通过本次实验,认识了PWM的使用方法,通过亲身体验,初步掌握了2812对PWM 的控制使用方法,加深了对PWM的认识。本次实验的主要目的是通过2812对直流电机的控制,开始对于程序的设计没有头绪,通过查阅直流电机的原理,结合有关资料才正式设计出程序,基本掌握了2812对直流电机的控制,也更加熟悉了对DSP程序的设计,受益匪浅。

附:实验程序:

#include "include/DSP281x_Device.h" // DSP281x Headerfile Include File

#include "include/DSP281x_Examples.h" // DSP281x Examples Include File

// Prototype statements for functions found within this file.

void init_eva(void);

void init_evb(void);

void delay_loop();

// Global variable for this example

main()

{ unsigned short i;

// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

// This example function is found in the DSP281x_SysCtrl.c file.

InitSysCtrl();

// Specific clock setting for this example:

EALLOW;

EDIS;

// Step 2. Initalize GPIO:

// This example function is found in the DSP281x_Gpio.c file and

// illustrates how to set the GPIO to it's default state.

// InitGpio(); // Skipped for this example

// Initialize only GPAMUX and GPBMUX for this test

相关主题
文本预览
相关文档 最新文档