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.

[参考译文] MSP430FR6989:#10099-D 程序不能放入可用的存储器中

Guru**** 2770655 points

Other Parts Discussed in Thread: MSP430FR6989

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1010222/msp430fr6989-10099-d-program-will-not-fit-into-available-memory

器件型号:MSP430FR6989

我正在尝试刷写 MSP430 DSP 库()中的 transform_ex1_FFT_fixed_Q15示例。 当我尝试刷写它时、我得到标题中提到的错误。 查看其他线程(相关问题)、我尝试更改堆栈和堆大小、以便生成主文件、并且可以查看映射文件。 但是、尝试从5到1000 (最初为160)范围内的堆栈和堆大小不起作用。 我尝试查看了"Memory Allocation"选项卡。 分配状态失败"使用-1个字节中的160个(-16000%)"、RAM 状态"使用2、408个字节中的2、408个(100%)"、FRAM 状态 "使用48、000个字节中的110个(0%)"、FRAM2状态"使用81、912个字节中的4、338个(5%)"。 可用存储器范围为:

RAM  大小:0x800  未使用:0x0  最大空洞:0x0

我还尝试使用第二个 MSP430FR6989、但得到的错误相同。 是否有人知道我如何才能看到导致此错误的原因、或者如果我的 MCU 只是没有足够的 FRAM (128KB)?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Samuel、

    感谢您提供内存分配结果。 如果您查看下面的链接器 cmd 文件、您可以看到.stack 段被放置在 RAM 中。 根据存储器分配结果、RAM 部分已完全填满、这就是.stack 部分无法放入存储器的原因。

    您还可以通过在工程 Debug 文件夹中的映射文件中进行验证。 在这里可以看到、.bss 段(对于未初始化的全局和静态变量、特别是变量 temp、cycleCount、input 和 Window)从 RAM (位置0x1c00)开始、并占用所有2KB 的 RAM。

    要解决此问题、您可以将 temp、Window 和输入变量移至 FRAM、因为它们占用大量空间。 我在下面附加了一个代码示例、其中使用#pragma PERSISTENT 将这些变量放置在.TI.persistent 中(链接器 cmd 文件位于 FRAM 中)。  下面是一 个有用的应用手册 、其中介绍了使用 FRAM 的最佳实践、 请参阅 第3节"变量"。

    /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, 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.
     * --/COPYRIGHT--*/
    //******************************************************************************
    // Real FFT with fixed scaling.
    //
    //! \example transform_ex1_fft_fixed_q15.c
    //! This example demonstrates how to use the msp_fft_fixed_q15 API to transform
    //! a real input data array to the frequency domain using the Q15 fast fourier
    //! transform (FFT) with fixed scaling. The real FFT function is identical to
    //! running a complex FFT with imaginary components set to zero. The result of
    //! the real FFT is a complex vector with half the samples but identical byte
    //! length.
    //!
    // Brent Peterson, Jeremy Friesenhahn
    // Texas Instruments Inc.
    // April 2016
    //******************************************************************************
    #include "msp430.h"
    
    #include <math.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    #include "DSPLib.h"
    
    /* Input signal parameters */
    #define FS                  8192
    #define SAMPLES             256
    #define SIGNAL_FREQUENCY1   200
    #define SIGNAL_AMPLITUDE1   0.6
    #define SIGNAL_FREQUENCY2   2100
    #define SIGNAL_AMPLITUDE2   0.15
    
    /* Hamming window parameters */
    #define HAMMING_ALPHA       0.53836
    #define HAMMING_BETA        0.46164
    
    /* Constants */
    #define PI                  3.1415926536
    
    /* Generated Hamming window function */
    DSPLIB_DATA(window,4)
    /* Declare as persistent to move variable to FRAM */
    #pragma PERSISTENT(window)
    _q15 window[SAMPLES] = {0};
    
    /* Input signal and FFT result */
    DSPLIB_DATA(input,MSP_ALIGN_FFT_Q15(SAMPLES))
    /* Declare as persistent to move variable to FRAM */
    #pragma PERSISTENT(input)
    _q15 input[SAMPLES] = {0};
    
    /* Temporary data array for processing */
    DSPLIB_DATA(temp,4)
    /* Declare as persistent to move variable to FRAM */
    #pragma PERSISTENT(temp)
    _q15 temp[3*SAMPLES/2] = {0};
    
    /* Benchmark cycle counts */
    volatile uint32_t cycleCount;
    
    /* Function prototypes */
    extern void initSignal(void);
    extern void initHamming(void);
    
    void main(void)
    {
        msp_status status;
        msp_mpy_q15_params mpyParams;
        msp_fft_q15_params fftParams;
    
        /* Disable WDT */
        WDTCTL = WDTPW + WDTHOLD;
    
    #ifdef __MSP430_HAS_PMM__
        /* Disable GPIO power-on default high-impedance mode for FRAM devices */
        PM5CTL0 &= ~LOCKLPM5;
    #endif
        
        /* Initialize input signal and Hamming window */
        initSignal();
        initHamming();
    
        /* Multiply input signal by generated Hamming window */
        mpyParams.length = SAMPLES;
        status = msp_mpy_q15(&mpyParams, input, window, input);
        msp_checkStatus(status);
    
        /* Initialize the fft parameter structure. */
        fftParams.length = SAMPLES;
        fftParams.bitReverse = true;
        fftParams.twiddleTable = MAP_msp_cmplx_twiddle_table_2048_q15;
    
        /* Perform real FFT with fixed scaling */
        msp_benchmarkStart(MSP_BENCHMARK_BASE, 16);
        status = MAP_msp_fft_fixed_q15(&fftParams, input);
        cycleCount = msp_benchmarkStop(MSP_BENCHMARK_BASE);
        msp_checkStatus(status);
        
        /* End of program. */
        __no_operation();
    }
    
    void initSignal(void)
    {
        msp_status status;
        msp_add_q15_params addParams;
        msp_sinusoid_q15_params sinParams;
    
        /* Generate Q15 input signal 1 */
        sinParams.length = SAMPLES;
        sinParams.amplitude = _Q15(SIGNAL_AMPLITUDE1);
        sinParams.cosOmega = _Q15(cosf(2*PI*SIGNAL_FREQUENCY1/FS));
        sinParams.sinOmega = _Q15(sinf(2*PI*SIGNAL_FREQUENCY1/FS));
        status = msp_sinusoid_q15(&sinParams, input);
        msp_checkStatus(status);
    
        /* Generate Q15 input signal 2 to temporary array */
        sinParams.length = SAMPLES;
        sinParams.amplitude = _Q15(SIGNAL_AMPLITUDE2);
        sinParams.cosOmega = _Q15(cosf(2*PI*SIGNAL_FREQUENCY2/FS));
        sinParams.sinOmega = _Q15(sinf(2*PI*SIGNAL_FREQUENCY2/FS));
        status = msp_sinusoid_q15(&sinParams, temp);
        msp_checkStatus(status);
    
        /* Add input signals */
        addParams.length = SAMPLES;
        status = msp_add_q15(&addParams, input, temp, input);
        msp_checkStatus(status);
    }
    
    void initHamming(void)
    {
        msp_status status;
        msp_sub_q15_params subParams;
        msp_copy_q15_params copyParams;
        msp_fill_q15_params fillParams;
        msp_sinusoid_q15_params sinParams;
    
        /* Generate sinusoid for cosine function */
        sinParams.length = 3*SAMPLES/2;
        sinParams.amplitude = _Q15(HAMMING_BETA);
        sinParams.cosOmega = _Q15(cosf(2*PI/(SAMPLES-1)));
        sinParams.sinOmega = _Q15(sinf(2*PI/(SAMPLES-1)));
        status = msp_sinusoid_q15(&sinParams, temp);
        msp_checkStatus(status);
    
        /* Shift sinusoid by pi/2 to create cosine function */
        copyParams.length = SAMPLES;
        status = msp_copy_q15(&copyParams, &temp[SAMPLES/4], &temp[0]);
        msp_checkStatus(status);
    
        /* Fill temporary array with alpha constant */
        fillParams.length = SAMPLES;
        fillParams.value = _Q15(HAMMING_ALPHA);
        status = msp_fill_q15(&fillParams, window);
        msp_checkStatus(status);
    
        /* Subtract generated cosine from alpha constant to generate final window */
        subParams.length = SAMPLES;
        status = msp_sub_q15(&subParams, window, temp, window);
        msp_checkStatus(status);
    }
    

    希望这对您有所帮助!

    此致、

    王国新

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    对于编程问题、这是我得到的最佳答案。 非常感谢、这两个问题都解决了、帮助我了解了我的错误。