用过dsPIC的大神帮忙看看, 编译通过,执行失败(报Y地址错誤)

2020-02-08 12:25发布

整个工程只有一个MAIN.C文件,内容如下,CPU选用dsPIC33FJ256gp710A,末尾附工程文件,编译可以通过,执行到 FFTComplexIP函数时仿真器报Y地址错,用的是MPLAB自带的软仿真.



#include <p33fxxxx.h>
#include <dsp.h>
//#include "fft.h"
//#include <math.h>
//#include <delay.h>


#define FFT_BLOCK_LENGTH        256   
#define LOG2_BLOCK_LENGTH         8       
//#define SAMPLING_RATE                256 //采样速度

//#define FFTTWIDCOEFFS_IN_PROGMEM //旋转因子在程序空间中

extern const fractcomplex twiddleFactors[] __attribute__ ((space(auto_psv), aligned (FFT_BLOCK_LENGTH*2)));


const fractcomplex twiddleFactors[] __attribute__ ((space(auto_psv), aligned (FFT_BLOCK_LENGTH*2)))=
{
        0x7FFF, 0x0000, 0x7FF6, 0xFCDC, 0x7FD9, 0xF9B8, 0x7FA7, 0xF695,
        0x7F62, 0xF374, 0x7F0A, 0xF055, 0x7E9D, 0xED38, 0x7E1E, 0xEA1E,
        0x7D8A, 0xE707, 0x7CE4, 0xE3F4, 0x7C2A, 0xE0E6, 0x7B5D, 0xDDDC,
        0x7A7D, 0xDAD8, 0x798A, 0xD7D9, 0x7884, 0xD4E1, 0x776C, 0xD1EF,
        0x7642, 0xCF04, 0x7505, 0xCC21, 0x73B6, 0xC946, 0x7255, 0xC673,
        0x70E3, 0xC3A9, 0x6F5F, 0xC0E9, 0x6DCA, 0xBE32, 0x6C24, 0xBB85,
        0x6A6E, 0xB8E3, 0x68A7, 0xB64C, 0x66CF, 0xB3C0, 0x64E8, 0xB140,
        0x62F2, 0xAECC, 0x60EC, 0xAC65, 0x5ED7, 0xAA0A, 0x5CB4, 0xA7BD,
        0x5A82, 0xA57E, 0x5843, 0xA34C, 0x55F6, 0xA129, 0x539B, 0x9F14,
        0x5134, 0x9D0E, 0x4EC0, 0x9B18, 0x4C40, 0x9931, 0x49B4, 0x9759,
        0x471D, 0x9592, 0x447B, 0x93DC, 0x41CE, 0x9236, 0x3F17, 0x90A1,
        0x3C57, 0x8F1D, 0x398D, 0x8DAB, 0x36BA, 0x8C4A, 0x33DF, 0x8AFB,
        0x30FC, 0x89BE, 0x2E11, 0x8894, 0x2B1F, 0x877C, 0x2827, 0x8676,
        0x2528, 0x8583, 0x2224, 0x84A3, 0x1F1A, 0x83D6, 0x1C0B, 0x831C,
        0x18F9, 0x8276, 0x15E2, 0x81E3, 0x12C8, 0x8163, 0x0FAB, 0x80F7,
        0x0C8C, 0x809E, 0x096B, 0x8059, 0x0648, 0x8028, 0x0324, 0x800A,
        0x0000, 0x8000, 0xFCDC, 0x800A, 0xF9B8, 0x8028, 0xF695, 0x8059,
        0xF374, 0x809E, 0xF055, 0x80F7, 0xED38, 0x8163, 0xEA1E, 0x81E3,
        0xE707, 0x8276, 0xE3F5, 0x831C, 0xE0E6, 0x83D6, 0xDDDC, 0x84A3,
        0xDAD8, 0x8583, 0xD7D9, 0x8676, 0xD4E1, 0x877C, 0xD1EF, 0x8894,
        0xCF04, 0x89BE, 0xCC21, 0x8AFB, 0xC946, 0x8C4A, 0xC673, 0x8DAB,
        0xC3A9, 0x8F1D, 0xC0E9, 0x90A1, 0xBE32, 0x9236, 0xBB85, 0x93DC,
        0xB8E3, 0x9593, 0xB64C, 0x975A, 0xB3C0, 0x9931, 0xB140, 0x9B18,
        0xAECC, 0x9D0E, 0xAC65, 0x9F14, 0xAA0A, 0xA129, 0xA7BD, 0xA34C,
        0xA57E, 0xA57E, 0xA34C, 0xA7BD, 0xA129, 0xAA0A, 0x9F14, 0xAC65,
        0x9D0E, 0xAECC, 0x9B18, 0xB140, 0x9931, 0xB3C0, 0x975A, 0xB64C,
        0x9593, 0xB8E3, 0x93DC, 0xBB85, 0x9236, 0xBE32, 0x90A1, 0xC0E9,
        0x8F1D, 0xC3A9, 0x8DAB, 0xC673, 0x8C4A, 0xC946, 0x8AFB, 0xCC21,
        0x89BF, 0xCF04, 0x8894, 0xD1EF, 0x877C, 0xD4E1, 0x8676, 0xD7D9,
        0x8583, 0xDAD8, 0x84A3, 0xDDDC, 0x83D6, 0xE0E6, 0x831C, 0xE3F5,
        0x8276, 0xE707, 0x81E3, 0xEA1E, 0x8163, 0xED38, 0x80F7, 0xF055,
        0x809E, 0xF374, 0x8059, 0xF695, 0x8028, 0xF9B8, 0x800A, 0xFCDC,
} ;


//============================================================================================================
//定义ADC值数组
int data[FFT_BLOCK_LENGTH]__attribute__ ((space (xmemory)));

//定义FFT源和结果数组
fractcomplex FFTData[FFT_BLOCK_LENGTH] __attribute__ ((aligned (FFT_BLOCK_LENGTH*4)));
//fractcomplex FFTData[FFT_BLOCK_LENGTH] __attribute__ ((space(ymemory), aligned (FFT_BLOCK_LENGTH*4))); //不能用ymemory编译会出错

int temp_fft_data_max, temp_fft_data_min;
int FFTPreProcessCnt;


int main(void)
{
  unsigned int i;

  for (i=0; i<FFT_BLOCK_LENGTH; i++)
  {
      data = 0;  
  }
  //在此从.MCH中加载ADC数组

  for (i=0; i<FFT_BLOCK_LENGTH; i++)
  {   
             FFTData.real = data;
      FFTData.imag = 0;
  }

FFTComplexIP (LOG2_BLOCK_LENGTH, FFTData, (fractcomplex *) __builtin_psvoffset(twiddleFactors), (int)__builtin_psvpage(twiddleFactors));   
BitReverseComplex (LOG2_BLOCK_LENGTH, FFTData);
  return 0;
}

另提供工程文件:

工程文件ourdev_658052KT5X4E.rar(文件大小:30K) (原文件名:dspic.rar)
0条回答

一周热门 更多>