This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
芯片:
LP-MSPM0G3507
launchpad
问题描述:
在调试模式并且无断点的状态下,程序无法正常运行,详细为:for循环无法搬运数据
在调试模式并且在无法正常运行的代码上。加断点(见图3)后直接reset并运行(不重新烧录)则程序能够正常运行
问题代码位置:
empty.c/60, 61
Hardware/easy_fft_v2.c/27
empty.c
/*
* Copyright (c) 2021, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ti_msp_dl_config.h"
#include "ti/driverlib/m0p/dl_core.h"
#include "LED.h"
#include "UART.h"
#include "ADC.h"
#include "stdio.h"
#include "string.h"
#include "easy_fft_v2.h"
#include <stdint.h>
#include "arm_math.h"
#define ADC_SampleSize 256
volatile bool adcflag;
uint16_t ADC_Buf0[ADC_SampleSize]={0};
fft_struct FFT;
float32_t ADC_Out0[ADC_SampleSize<<1]= {0};
// easy_fft_256_t fft0;
uint32_t frequency;
int main(void)
{
SYSCFG_DL_init();
ADC_Start(ADC_Buf0, ADC_SampleSize,98050,1);
easyFFT_init(&FFT , 256, ADC_Buf0 ,ADC_Out0, 5000000);
easyFFT_mach(&FFT);
// easyFFT_Ampl(&FFT);
//easy_fft_process_256_without_dc(ADC_Buf0, 5000000, &fft0, 3.3);
while (1) {
if (adcflag == true)
{
adcflag = false;
}
}
}
int fputc(int c,FILE*stream)
{
DL_UART_Main_transmitDataBlocking(UART_0_INST,c);
return c;
}
int fputs(const char*restrict s,FILE* restrict stream)
{
uint16_t i,len;
len = strlen(s);
for (i=0;i<len;++i)
{
DL_UART_Main_transmitDataBlocking(UART_0_INST,s[i]);
}
return len;
}
int puts(const char*_ptr)
{
int count = fputs(_ptr,stdout);
count+=fputs("\n",stdout);
return count;
}
// uint32_t getFrequency (uint16_t *Buf, )
eassy_fft_v2.c
#include "easy_fft_v2.h"
#include "arm_const_structs.h"
void easyFFT_init(fft_struct *fft_struct_data , uint16_t length, uint16_t *fft_in_data, float32_t *fft_out_data, float32_t adc_fre){
fft_struct_data -> length = length;
fft_struct_data -> adc_fre = adc_fre;
fft_struct_data -> adc_fre_div = adc_fre/length;
fft_struct_data -> fft_in_data = fft_in_data;
fft_struct_data -> fft_out_data = fft_out_data;
switch (length)
{
case 1024:
fft_struct_data -> fft_type = &arm_cfft_sR_f32_len1024;
break;
case 2048:
fft_struct_data -> fft_type = &arm_cfft_sR_f32_len2048;
break;
case 4096:
fft_struct_data -> fft_type = &arm_cfft_sR_f32_len4096;
break;
default:
fft_struct_data -> fft_type = &arm_cfft_sR_f32_len256;
break;
}
}
void easyFFT_moveData(fft_struct *fft_struct_data){
for(uint16_t i=0; i<fft_struct_data->length; i++){
fft_struct_data->fft_out_data[i<<1] = fft_struct_data->fft_in_data[i];
fft_struct_data->fft_out_data[(i<<1) + 1] = 0;
}
arm_cfft_f32(fft_struct_data->fft_type, fft_struct_data->fft_out_data, 0, 1);
}
void easyFFT_mach(fft_struct *fft_struct_data){
easyFFT_moveData(fft_struct_data);
}
void easyFFT_Ampl(fft_struct *fft_struct_data){
arm_cmplx_mag_f32(fft_struct_data->fft_out_data, fft_struct_data->fft_out_data, fft_struct_data->length);
}
float32_t easyFFT_getAmpl(fft_struct *fft_struct_data, float32_t fre){
uint16_t ans_index = findNearest(0, fft_struct_data->adc_fre_div, fre);
float32_t ans;
arm_sqrt_f32(fft_struct_data->fft_out_data[ans_index*2]*fft_struct_data->fft_out_data[ans_index*2] + fft_struct_data->fft_out_data[ans_index*2 + 1]*fft_struct_data->fft_out_data[ans_index*2 + 1], &ans);
return ans;
}
float32_t easyFFT_getAmpl_afterAmpl(fft_struct *fft_struct_data, float32_t fre){
uint16_t ans_index = findNearest(0, fft_struct_data->adc_fre_div, fre);
return fft_struct_data->fft_out_data[ans_index];
}
float32_t findNearest(float32_t start_value, float32_t step, float32_t aim_value){
uint16_t num_flot = (aim_value - start_value)/step;
float32_t num_low = start_value + num_flot*step;
float32_t num_high = start_value + (num_flot + 1)*step;
if((num_high - aim_value) > (aim_value - num_low)){
return num_flot;
}else{
return num_flot+1;
}
}
编译器存在一些问题
尝试在此处添加注释:
while (1) { __NOP(); if (adcflag == true) { adcflag = false; } }