ArduinoFHT implementation on photon device

Hi all, Im trying to implement the Arduino FHT (http://wiki.openmusiclabs.com/wiki/ArduinoFHT) library into my particle device, I looked at it into the particle repository and found the library but at the time of implement the example depict in the developer webpage - http://wiki.openmusiclabs.com/wiki/FHTExample - but looking at the particle library implementation I don’t know how to use the library, can somebody share some lights on how to implement these library? thanks all.

Jaime

Hi all, I found the FHT Library in the particle repository

particle library search fht
Found 1 library matching fht
ArduinoFHT4 4.0.0 39

Everything went smothly to integrate it with my project following the instruction in the example file, but when I try to compile use any fht function (fht_window()) this error came up:

In file included from /Users/jaimelabra/Documents/Projects/firmware/Intercom_v3/v10/lib/ArduinoFHT4/src/ArduinoFHT4.cpp:9:0:
/Users/jaimelabra/Documents/Projects/firmware/Intercom_v3/v10/lib/ArduinoFHT4/src/FHT/FHT.h: In member function 'void ArduinoFHT4::process()':
/Users/jaimelabra/Documents/Projects/firmware/Intercom_v3/v10/lib/ArduinoFHT4/src/FHT/FHT.h:1242:4error: unknown register name 'r23' in 'asm'
);
^
/Users/jaimelabra/Documents/Projects/firmware/Intercom_v3/v10/lib/ArduinoFHT4/src/FHT/FHT.h:1242:4error: unknown register name 'r22' in 'asm'
/Users/jaimelabra/Documents/Projects/firmware/Intercom_v3/v10/lib/ArduinoFHT4/src/FHT/FHT.h:1242:4error: unknown register name 'r31' in 'asm'
/Users/jaimelabra/Documents/Projects/firmware/Intercom_v3/v10/lib/ArduinoFHT4/src/FHT/FHT.h:1242:4error: unknown register name 'r30' in 'asm'
/Users/jaimelabra/Documents/Projects/firmware/Intercom_v3/v10/lib/ArduinoFHT4/src/FHT/FHT.h:1242:4error: unknown register name 'r20' in 'asm'

this is refering to this part of the FHT.h file

asm volatile (
  "ldi r28, lo8(fht_input) \n" // set to beginning of data space
  "ldi r29, hi8(fht_input) \n"
  "ldi r30, lo8(_window_func) \n" // set to beginning of lookup table
  "ldi r31, hi8(_window_func) \n"
  "clr r15 \n" // prep null register
  "ldi r20, " STRINGIFY(((FHT_N)&(0xff))) " \n"

  "1: \n"
  "lpm r22,z+ \n" // fetch window value
  "lpm r23,z+ \n"
  "ld r16,y \n" // fetch data
  "ldd r17,y+1 \n"

  // multiply by window
  "fmuls r17,r23 \n"
  "movw r4,r0 \n"
  "fmul r16,r22 \n"
  "adc r4,r15 \n"
  "movw r2,r0 \n"
  "fmulsu r17,r22 \n"
  "sbc r5,r15 \n"
  "add r3,r0 \n"
  "adc r4,r1 \n"
  "adc r5,r15 \n"
  "fmulsu r23,r16 \n"
  "sbc r5,r15 \n"
  "add r3,r0 \n"
  "adc r4,r1 \n"
  "adc r5,r15 \n"

  "st y+,r4 \n" // restore data
  "st y+,r5 \n"
  "dec r20 \n" // check if done
  "brne 1b \n"
  : :
  : "r0", "r20", "r30", "r31", "r22", "r23" // clobber list <= the error refer to this part
  );

Can somebody share some lights how to overcome these error, all help are well appreciate it.

thanks!
Jaime.

As far as I can see, that library has just been uploade to the library repo but wasn’t really ported for the Particle ecosystem.

Look at the “implementation” file
https://build.particle.io/libs/ArduinoFHT4/4.0.0/tab/ArduinoFHT4.cpp


@bsatrom, I think this is a library that needs to be taken down.
The library.properties don’t state any source repo nor contact info for the contributor and it’s mostly asm which won’t be easily ported over to STM32 or nRF52840

1 Like

@jaime, here is an article with some C code which may be usable on the Particle platform.

https://m.eet.com/media/1175816/f-scott.pdf

2 Likes

Thanks @peekay123 I’ll look at it!

1 Like

Thanks for the ping @ScruffR, I’ll get it removed.

Hi all, I have found another library for those who are trying with FFT, https://github.com/kosme/arduinoFFT for now it works good!

Jaime

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.