请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
部件号:MSP430FR5994 “线程”中讨论的其它部件:ENERGY-TRACE, ABS
我正在尝试使用 EnergyTrace 技术优化代码以降低功耗。 我使用以下函数:
static void amplify_data(void)
{
volatile uint16_t cnt = 0;
volatile uint16_t newval = 0;
for(cnt = 0; cnt < SAMPLES_LENGTH; cnt++)
{
newval = __data20_read_short(&dataRecorded1[cnt]);
newval = newval << 2;
__data20_write_short(&dataRecorded1[cnt], newval);
}
}
我用倒计时配置替换 for 循环,因为我发现它可以节省一些能量。 但是,当我使用此配置运行代码时,我会收到上面标题中提到的消息。 我看了不同 MSP 设备出现的类似问题,但这些解决方案都没有奏效——我尝试更改代码的优化级别,确保堆栈有足够的空间,并且没有溢出,但问题仍然存在。 我不确定到底是什么原因会引发此问题-我想特别删除它,因为我的后一个代码的执行因该点后代码停止而受到阻碍。 我使用上述函数的代码如下所示:
#define VECTOR_SIZE (512)
#pragma DATA_SECTION(signal_fft, ".leaRAM")
DSPLIB_DATA(signal_fft,MSP_ALIGN_FFT_Q15(VECTOR_SIZE))
_q15 signal_fft[VECTOR_SIZE] = {0};
DSPLIB_DATA(fft_res,MSP_ALIGN_FFT_Q15(VECTOR_SIZE))
_q15 fft_res[VECTOR_SIZE] = {0};
_q15 FFT_data[VECTOR_SIZE] = {0};
msp_fft_q15_params realFftParams;
msp_add_q15_params addParams;
int16_t window_number = 0;
int16_t imag, real;
uint16_t real_abs, imag_abs, mag, max, min;
uint16_t clock_count = 0;
static void fft_init(void)
{
realFftParams.length = 512;
realFftParams.twiddleTable = msp_cmplx_twiddle_table_256_q15; // Table not needed when using LEA
realFftParams.bitReverse = 1; // Since input is not already in bit reversed order
addParams.length = 512;
}
static void fft_cal(void)
{
volatile msp_status status;
volatile uint16_t i;
for(i = 0; i < VECTOR_SIZE; i++)
{
// Last window is short by 1
// Array is of 32767 and not 32768
if (window_number == 63)
{
if (i == (VECTOR_SIZE - 1))
{
signal_fft[i] = 0;
}
else
{
signal_fft[i] = (_q15)__data20_read_short(&dataRecorded1[(VECTOR_SIZE*window_number)+i]);
}
}
else
{
signal_fft[i] = (_q15)__data20_read_short(&dataRecorded1[(VECTOR_SIZE*window_number)+i]);
}
}
status = msp_fft_fixed_q15(&realFftParams,signal_fft);
if (status != MSP_SUCCESS)
{
__no_operation();
}
status = msp_add_q15(&addParams, signal_fft, fft_res, fft_res);
if (status != MSP_SUCCESS)
{
__no_operation();
}
memset(signal_fft, 0, sizeof(signal_fft));
window_number++;
}
}
/* Since internal reference voltage is not being used, mic o/p through ADC is low. Multiply by 4. */
static void amplify_data(void)
{
unsigned int cnt;
uint16_t newval=0;
for(cnt = 0; cnt < SAMPLES_LENGTH; cnt++)
{
newval = __data20_read_short(&dataRecorded1[cnt]);
newval = newval << 2;
__data20_write_short(&dataRecorded1[cnt], newval);
}
}
void runApplication(void)
{
while(1)
{
P5IE &= ~BIT7; // Disable interrupt on P5.7 // vm1010
P5IE &= ~BIT6; // Disable interrupt on P5.6
P5IE &= ~BIT5; // Disable interrupt on P5.5
// Disable button interrupt
GPIO_disableInterrupt(PUSHBUTTON1_PORT, PUSHBUTTON1_PIN);
switch(applicationMode)
{
volatile uint16_t j;
case RECORD:
runRecord();
amplify_data();
fft_init();
while(window_number < 64)
{
fft_cal();
}
window_number=0;
/* Code continues */
如果我能得到关于我可能需要实施哪些更改或缺少的任何设置的任何建议,这将非常有帮助。 谢谢你。