Trying to use KISS_FFT library on microchip studio

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Hello everyone!

Im kinda new to the compilers concept.

a little context, im trying to use an IIS (MEMS) to read aceleration data, and then aplying a fft to the data, I start getting the data whit an interruption (interruption is defined as button_on_PA14_pressed)), I have setted the interruption and I can get the aceleration data whitout a problem, but the fft is not working (im using KISS_FFT https://github.com/mborgerding/k...) I get the following error:

Im guessing im not installing the library in the rigth way, what I did was to create a folder whit the name:

CUSTOM_DRIVER inside this folder I created a folder named KISS_FFT, then i downloaded the entire content of the GitHub page and then I added all the content of that GitHub to the KISS_FFT (rigth click on KISS_FFT and then add->existing item), finally i went to <project name> properties -> ARM/GNU C Compiler -> Directories 

And there I added the path to the files I added.



The code I used was:

 

#include <atmel_start.h>

#include "kiss_fft.h"

#include "kiss_fft_log.h"

#include "kiss_fftnd.h"

#include "kiss_fftndr.h"

#include "kiss_fftr.h"

#include "IIS2DH_driver.h"

#define ISS2DH_ADDR 24


#define THR 30//31 o 33

#define DURATION 3



volatile kiss_fft_scalar Z_data[500]={0x0};

volatile kiss_fft_cpx Z_fft;


uint32_t LIM=94; 

static void button_on_PA14_pressed(void)

{

    for (int i=0;i<LIM;i++)

    {

        Z_data[i]=IIS_get_Z(); //IIS_get_Z() read the data of the MEMS

    }

    

    kiss_fftr_cfg cfg = kiss_fftr_alloc(LIM,0,NULL,NULL);

    

    kiss_fftr(cfg,&Z_data,&Z_fft);

}


int main(void)

{

    /* Initializes MCU, drivers and middleware */

    atmel_start_init();

    

    SET THE IIS TO WORK IN THE RIGTH WAY, THIS IS SOLVED AND IT WORK FINE

    

    ext_irq_register(PIN_PA14, button_on_PA14_pressed);

    

    

    /* Replace with your application code */

    while (1) {

    }

}

 

 

Last Edited: Tue. May 10, 2022 - 09:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your taking a project aimed at bigger micros or even at hosted environments and compiling for AVR

There is code like this littered throughout:

    if ( ptr - (char*)st != (int)memneeded ) {
        fprintf(stderr,
                "################################################################################\n"
                "Internal error! Memory allocation miscalculation\n"
                "################################################################################\n"
               );
    }

That fprintf will cause your link error.

 

The Solution: Either delete every write write to stderr or implement some basic character stream handler. that sends stuff to a UART or screen or even the bit-bin. (a dev/null equivalent)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Two FFTs that would work for an AVR micro...

 

http://elm-chan.org/works/akilcd... (see fftavr.zip link at bottom of page).

 

https://www.arduino.cc/reference...

 

Or, to follow on from Nigel's post you could do an FDEV_SETUP_STREAM that basically has a putchar() to NULL then assign the stream to stderr. Then all the error stuff will still be there but it will "print to nowhere"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What sort of AVR though?

 

"PIN_PA14" ??????

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good point, from:

 

https://www.avrfreaks.net/forum/...

 

So it seems OP is using  ATSAML10E1A - sure would have helped to mention this at the start as AVR related answers (which is kind of what you are going to get when you post in the AVR section of the site!) are not going to be very relevant.

 

Thing is that the micro appears to be Cortex M23 which is one of the lowest level Cortex cores so I fear OP may face similar issues as if trying to do this on an AVR anyway - it's certainly not going to have a hosted OS.

 

Anyway I will move this to an ARM forum...