We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, i tried the arm dsp library for FFT and binning with FPB-RA0E1 board. I added the library in stack tab in e2 studio and add the code inside hal entry and tried to build. i got build error with flash over flow as flown below.
Step i followed.
create new bare metal project for FPB-RA0E1 board and R7FA0E1073CFJ device and add example code ( find from google for for STM and modified)
#include "hal_data.h"#include <../ra/arm/CMSIS-DSP/include/dsp/transform_functions.h>
FSP_CPP_HEADERvoid R_BSP_WarmStart(bsp_warm_start_event_t event);FSP_CPP_FOOTER
/*******************************************************************************************************************//** * main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used. This function * is called by main() when no RTOS is used. **********************************************************************************************************************/void hal_entry(void){ /* TODO: add your own code here */
/* * CMSIS FFT */ #define SAMPLE_BUFFER_LENGTH 4096 #define SAMPLE_BUFFER_LENGTH_HALF (SAMPLE_BUFFER_LENGTH/2) #define SAMPLING_RATE 48000
float32_t fft_input[SAMPLE_BUFFER_LENGTH]; float32_t fft_output[SAMPLE_BUFFER_LENGTH]; float32_t fft_power[SAMPLE_BUFFER_LENGTH_HALF];
uint8_t ifftFlag = 0; float frequency_resolution = (float)SAMPLING_RATE / (float)SAMPLE_BUFFER_LENGTH;
/* write signal to array */ for (int i = 0; i < SAMPLE_BUFFER_LENGTH; i++) { float32_t r = (float32_t)i/ (float32_t)SAMPLING_RATE; r *= 3.14159265359 * 2; r *= 880; // frequency in Hz float s = sin(r) + sin(r * 4) * 0.5 + sin(r * 3) * 0.25; fft_input[i] = s; }
/* analyze signal */ arm_rfft_fast_instance_f32 fft; arm_rfft_fast_init_f32(&fft, (uint16_t)SAMPLE_BUFFER_LENGTH); arm_rfft_fast_f32(&fft, fft_input, fft_output, ifftFlag); arm_cmplx_mag_f32(fft_output, fft_power, (uint32_t)SAMPLE_BUFFER_LENGTH_HALF); for (int i = 1; i < SAMPLE_BUFFER_LENGTH_HALF; i++) { //Serial.printf("%i\tfrq: %.1f\tenergy %.6f\r\n", i, i * frequency_resolution, fft_power[i]);// APP_PRINT("\r\n %i\tfrq: %.1f\tenergy %.6f \r\n", i, i * frequency_resolution, fft_power[i]); }
/* find dominant frequency */ float32_t maxValue; uint32_t maxIndex; arm_max_f32(fft_power, SAMPLE_BUFFER_LENGTH_HALF, &maxValue, &maxIndex); // Serial.printf("\r\n"); // Serial.printf("max power: %f\r\n", maxValue); // Serial.printf("max index: %i\r\n", maxIndex); // Serial.printf("frequency: %f\r\n", (maxIndex * frequency_resolution));// APP_PRINT("\r\n max power: %f\r\n", maxValue);// APP_PRINT("\r\n max index: %i\r\n", maxIndex);// APP_PRINT("\r\n frequency: %f\r\n", (maxIndex * frequency_resolution));
#if BSP_TZ_SECURE_BUILD /* Enter non-secure code */ R_BSP_NonSecureEnter();#endif}
/*******************************************************************************************************************//** * This function is called at various points during the startup process. This implementation uses the event that is * called right before main() to set up the pins. * * @param[in] event Where at in the start up process the code is currently at **********************************************************************************************************************/void R_BSP_WarmStart(bsp_warm_start_event_t event){ if (BSP_WARM_START_RESET == event) {#if BSP_FEATURE_FLASH_LP_VERSION != 0
/* Enable reading from data flash. */ R_FACI_LP->DFLCTL = 1U;
/* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and * C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */#endif }
if (BSP_WARM_START_POST_C == event) { /* C runtime environment and system clocks are setup. */
/* Configure pins. */ R_IOPORT_Open (&IOPORT_CFG_CTRL, &IOPORT_CFG_NAME);
#if BSP_CFG_SDRAM_ENABLED
/* Setup SDRAM and initialize it. Must configure pins first. */ R_BSP_SdramInit(true);#endif }}
#if BSP_TZ_SECURE_BUILD
FSP_CPP_HEADERBSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ();
/* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable (){
}FSP_CPP_FOOTER
#endif
while building this code getting the flowing error,
make -r -j8 all
Building target: CMSIS_FFT_Dummy.elf
C:/Users/1064238/AppData/Local/Programs/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: CMSIS_FFT_Dummy.elf section `.text' will not fit in region `FLASH'
C:/Users/1064238/AppData/Local/Programs/Renesas/RA/e2studio_v2024-10_fsp_v5.6.0/toolchains/gcc_arm/13.2.rel1/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 38348 bytes
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:111: CMSIS_FFT_Dummy.elf] Error 1
"make -r -j8 all" terminated with exit code 2. Build might be incomplete.