好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

经过多天的调试,终于调通了,为了方便大家少走弯路,带.doc

5页
  • 卖家[上传人]:ldj****22
  • 文档编号:31481008
  • 上传时间:2018-02-08
  • 文档格式:DOC
  • 文档大小:32KB
  • / 5 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 经过多天的调试,终于调通了,为了方便大家少走弯路,带来痛苦,提高效率,下面将我的感受和源程序写出来,供大家学习!!希望大家共同交流!这个我已经运行了,通过了,大家做的时候先用 matlab 验证一下 sin 的频率!然后看计算结果对不!2005.04.7 号上午八点 40 程序纪录,这个程序运算完全正确,和前一个程序不同之处在 sin 值得大小,由于 2812 时定点运算,sin 值得大小不能太小!否则计算结果为零!2812 的 fft 的错误在于 fft.init1(),fft.init2()这两个函数没有这函数库里面定义,而是该用 fft.init(&fft),而且由于是定点运算,输入的 sin 值不能太小,要不然计算结果为零!#include "DSP281x_Device.h" // DSP281x Headerfile Include File#include "DSP281x_Examples.h" // DSP281x Examples Include File#include "fft.h"#include #define BUF_SIZE 128#pragma DATA_SECTION(ipcb, "FFTipcb");#pragma DATA_SECTION(mag, "FFTmag");// Prototype statements for functions found within this file.// Global variables used in this example:Uint16 LoopCount;Uint16 ConversionCount;Uint16 fftflag=0;//FFT 转换启动标志:0 不启动;1:启动Uint16 i;long Voltage1[BUF_SIZE];long Voltage2[BUF_SIZE];long ipcb[BUF_SIZE];RFFT32 fft=RFFT32_128P_DEFAULTS;//CFFT32 fft=CFFT32_128P_DEFAULTS;long mag[BUF_SIZE/2+1];const long win[BUF_SIZE/2]=HANNING128;int x1;long k=0;double j=0.12345;main(){Uint16 i;// Step 1. Initialize System Control:// PLL, WatchDog, enable Peripheral Clocks// This example function is found in the DSP281x_SysCtrl.c file.InitSysCtrl();// For this example, set HSPCLK to SYSCLKOUT / 6 (25Mhz assuming 150Mhz SYSCLKOUT)EALLOW;SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK = SYSCLKOUT/6EDIS;// Step 2. Initialize 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 // 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();// Interrupts that are used in this example are re-mapped to// ISR functions found within this file. // EALLOW; // This is needed to write to EALLOW protected register// PieVectTable.ADCINT = // EDIS; // This is needed to disable write to EALLOW protected registers// Step 4. Initialize all the Device Peripherals:// This function is found in DSP281x_InitPeripherals.c// InitPeripherals(); // Not required for this exampleInitAdc(); // For this example, init the ADC// Step 5. User specific code, enable interrupts:PieCtrlRegs.PIEIER1.bit.INTx6 = 1;IER |= M_INT1; // Enable CPU Interrupt 1EINT; // Enable Global interrupt INTMERTM; // Enable Global realtime interrupt DBGMLoopCount = 0;ConversionCount = 0;for(i=0;ibuild options, linker tab, library search path (-i)./*========================================================= */MEMORY{PAGE 0 :/* For this example, H0 is split between PAGE 0 and PAGE 1 */ /* BEGIN is used for the "boot to HO" bootloader mode *//* RESET is loaded with the reset vector only if *//* the boot is from XINTF Zone 7. Otherwise reset vector *//* is fetched from boot ROM. See .reset section below */RAMM0 : origin = 0x000000, length = 0x000400BEGIN : origin = 0x3F8000, length = 0x000002 PRAMH0 : origin = 0x3F8002, length = 0x000FFERESET : origin = 0x3FFFC0, length = 0x000002 PAGE 1 : /* For this example, H0 is split between PAGE 0 and PAGE 1 */RAMM1 : origin = 0x000400, length = 0x000400DRAMH0 : origin = 0x3f9000, length = 0x001000 }SECTIONS{/* Setup for "boot to H0" mode: The codestart section (found in DSP28_CodeStartBranch.asm)re-directs execution to the start of user code. Place this section at the start of H0 */codestart : > BEGIN, PAGE = 0ramfuncs : > PRAMH0 PAGE = 0 .text : > PRAMH0, PAGE = 0.cinit : > PRAMH0, PAGE = 0.pinit : > PRAMH0, PAGE = 0.switch : > RAMM0, PAGE = 0.reset : > RESET, PAGE = 0, TYPE = DSECT /* not used, */ FFTtf > PRAMH0, PAGE = 0 FFTipcb ALIGN(256): {}> DRAMH0, PAGE = 1FFTmag > DRAMH0, PAGE = 1.stack : > RAMM1, PAGE = 1.ebss : > DRAMH0, PAGE = 1.econst : > DRAMH0, PAGE = 1 .esysmem : > DRAMH0, PAGE = 1}。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.