'TIMSK0' was not declared in this scope; did you mean 'TIM10'?

can anyone tell me why this won't compile?

/*
fht_adc.pde
guest openmusiclabs.com 9.5.12
example sketch for testing the fht library.
it takes in data on ADC0 (Analog0) and processes them
with the fht. the data is sent out over the serial
port at 115.2kb.  there is a pure data patch for
visualizing the data.
*/

#define LOG_OUT 1 // use the log output function
#define FHT_N 256 // set to 256 point fht

#include <FHT.h> // include the library

void setup() {
  Serial.begin(115200); // use the serial port
  TIMSK0 = 0; // turn off timer0 for lower jitter
  ADCSRA = 0xe5; // set the adc to free running mode
  ADMUX = 0x40; // use adc0
  DIDR0 = 0x01; // turn off the digital input for adc0
}

void loop() {
  while(1) { // reduces jitter
    cli();  // UDRE interrupt slows this way down on arduino1.0
    for (int i = 0 ; i < FHT_N ; i++) { // save 256 samples
      while(!(ADCSRA & 0x10)); // wait for adc to be ready
      ADCSRA = 0xf5; // restart adc
      byte m = ADCL; // fetch adc data
      byte j = ADCH;
      int k = (j << 8) | m; // form into an int
      k -= 0x0200; // form into a signed int
      k <<= 6; // form into a 16b signed int
      fht_input[i] = k; // put real data into bins
    }
    fht_window(); // window the data for better frequency response
    fht_reorder(); // reorder the data before doing the fht
    fht_run(); // process the data in the fht
    fht_mag_log(); // take the output of the fht
    sei();
    Serial.write(255); // send a start byte
    Serial.write(fht_log_out, FHT_N/2); // send out the data
  }
}
Arduino: 1.8.10 (Mac OS X), Board: "Generic STM32F4 series, BlackPill F411CE, STM32CubeProgrammer (Serial), Enabled (generic 'Serial'), None, Low/Full Speed, Smallest (-Os default), Newlib Nano (default)"

/Users/lee/Documents/Arduino/libraries/FHT/examples/fht_adc/fht_adc.pde: In function 'void setup()':
fht_adc:18:3: error: 'TIMSK0' was not declared in this scope; did you mean 'TIM10'?
   18 |   TIMSK0 = 0; // turn off timer0 for lower jitter
      |   ^~~~~~
      |   TIM10
fht_adc:19:3: error: 'ADCSRA' was not declared in this scope; did you mean 'ADC_SQR1'?
   19 |   ADCSRA = 0xe5; // set the adc to free running mode
      |   ^~~~~~
      |   ADC_SQR1
fht_adc:20:3: error: 'ADMUX' was not declared in this scope
   20 |   ADMUX = 0x40; // use adc0
      |   ^~~~~
fht_adc:21:3: error: 'DIDR0' was not declared in this scope
   21 |   DIDR0 = 0x01; // turn off the digital input for adc0
      |   ^~~~~
/Users/lee/Documents/Arduino/libraries/FHT/examples/fht_adc/fht_adc.pde: In function 'void loop()':
fht_adc:26:5: error: 'cli' was not declared in this scope; did you mean 'cbi'?
   26 |     cli();  // UDRE interrupt slows this way down on arduino1.0
      |     ^~~
      |     cbi
fht_adc:28:15: error: 'ADCSRA' was not declared in this scope; did you mean 'ADC_SQR1'?
   28 |       while(!(ADCSRA & 0x10)); // wait for adc to be ready
      |               ^~~~~~
      |               ADC_SQR1
fht_adc:29:7: error: 'ADCSRA' was not declared in this scope; did you mean 'ADC_SQR1'?
   29 |       ADCSRA = 0xf5; // restart adc
      |       ^~~~~~
      |       ADC_SQR1
fht_adc:30:16: error: 'ADCL' was not declared in this scope; did you mean 'ADC1'?
   30 |       byte m = ADCL; // fetch adc data
      |                ^~~~
      |                ADC1
fht_adc:31:16: error: 'ADCH' was not declared in this scope; did you mean 'ADC1'?
   31 |       byte j = ADCH;
      |                ^~~~
      |                ADC1
fht_adc:41:5: error: 'sei' was not declared in this scope; did you mean 'sbi'?
   41 |     sei();
      |     ^~~
      |     sbi
Multiple libraries were found for "FHT.h"
 Used: /Users/lee/Documents/Arduino/libraries/FHT
Multiple libraries were found for "SrcWrapper.h"
 Used: /Users/lee/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/libraries/SrcWrapper
exit status 1
'TIMSK0' was not declared in this scope; did you mean 'TIM10'?

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

(deleted)

Which Arduino board have you got and which Arduino board was the software written for.
Programs which directly address hardware registers etc. are not necessarily portable between Arduino boards.
crossed with @Spycatcher

Gotcha!
So how can I:
// turn off timer0 for lower jitter
Using stm32f4?

You're going to need to re-write pretty much the whole program to work on your STM32.

As it currently exists, the program is written based on AVR low-level peripheral access, rather than "The Arduino System", and the STM32 peripherals are completely different than the AVR peripherals.
In addition, that FTH library is full of inline AVR assembly language, which also won't work on your STM32.

You need to get a new FTH library or get a different (AVR-based) Arduino. :frowning:

On the plus side, the STM32F4xx should be so much faster than the AVR that a practical FHT should be a lot easier to write.

Thanks for the explanation