Hello friends
I'm trying to get some programming skills. I am beginning to understand what is happening in the code, but I do not understand the ejection ...
It's about this code, which is below. I only connected the naked Esp32 v4 and
just wanted to test the code.
When I start the serial monitor, it throws me out completely:
⸮⸮ 5⸮⸮⸮ 5⸮⸮⸮⸮⸮i
It goes on and on. Why and what does that mean?
Shouldn't that actually appear as a result ?:
Serial.println ("Can't set ITimer0. Select another freq. Or timer");
The other question is ... where can I find the result so that I can use it further?
here? -> TimerHandler0 ()
RPM_Measure.ino
 For ESP32 boards
 Written by Khoi Hoang
 Built by Khoi Hoang https://github.com/khoih-prog/ESP32TimerInterrupt
 Licensed under MIT license
 The ESP32 has two timer groups, each one with two general purpose hardware timers. All the timers are based on 64 bits
 counters and 16 bit prescalers. The timer counters can be configured to count up or down and support automatic reload
 and software reload. They can also generate alarms when they reach a specific value, defined by the software. The value
 of the counter can be read by the software program.
 Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
 unsigned long miliseconds), you just consume only one ESP32 timer and avoid conflicting with other cores' tasks.
 The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
 Therefore, their executions are not blocked by bad-behaving functions / tasks.
 This important feature is absolutely necessary for mission-critical tasks.
 Based on SimpleTimer - A timer library for Arduino.
 Author: mromani@ottotecnica.com
 Copyright (c) 2010 OTTOTECNICA Italy
 Based on BlynkTimer.h
 Author: Volodymyr Shymanskyy
 Version: 1.1.0
 Version Modified By Date   Comments
 ------- ----------- ---------- -----------
  1.0.0 K Hoang   23/11/2019 Initial coding
  1.0.1 K Hoang   27/11/2019 No v1.0.1. Bump up to 1.0.2 to match ESP8266_ISR_TimerInterupt library
  1.0.2 K.Hoang   03/12/2019 Permit up to 16 super-long-time, super-accurate ISR-based timers to avoid being blocked
  1.0.3 K.Hoang   17/05/2020 Restructure code. Add examples. Enhance README.
  1.1.0 K.Hoang   27/10/2020 Restore cpp code besides Impl.h code to use if Multiple-Definition linker error.
*****************************************************************************************************************************/
/*
 Notes:
 Special design is necessary to share data between interrupt code and the rest of your program.
 Variables usually need to be "volatile" types. Volatile tells the compiler to avoid optimizations that assume
 variable can not spontaneously change. Because your function may change variables while your program is using them,
 the compiler needs this hint. But volatile alone is often not enough.
 When accessing shared variables, usually interrupts must be disabled. Even with volatile,
 if the interrupt changes a multi-byte variable between a sequence of instructions, it can be read incorrectly.
 If your data is multiple variables, such as an array and a count, usually interrupts need to be disabled
 or the entire sequence of your code which accesses the data.
 RPM Measuring uses high frequency hardware timer 1Hz == 1ms) to measure the time from of one rotation, in ms
 then convert to RPM. One rotation is detected by reading the state of a magnetic REED SW or IR LED Sensor
 Asssuming LOW is active.
 For example: Max speed is 600RPM => 10 RPS => minimum 100ms a rotation. We'll use 80ms for debouncing
 If the time between active state is less than 8ms => consider noise.
 RPM = 60000 / (rotation time in ms)
 We use interrupt to detect whenever the SW is active, set a flag then use timer to count the time between active state
 RPM Measuring uses high frequency hardware timer 1Hz == 1ms) to measure the time from of one rotation, in ms
 then convert to RPM. One rotation is detected by reading the state of a magnetic REED SW or IR LED Sensor
 Asssuming LOW is active.
 For example: Max speed is 600RPM => 10 RPS => minimum 100ms a rotation. We'll use 80ms for debouncing
 If the time between active state is less than 8ms => consider noise.
 RPM = 60000 / (rotation time in ms)
 You can also use interrupt to detect whenever the SW is active, set a flag then use timer to count the time between active state
*/
#ifndef ESP32
 #error This code is designed to run on ESP32 platform, not Arduino nor ESP8266! Please check your Tools->Board setting.
#endif
// These define's must be placed at the beginning before #include "ESP32TimerInterrupt.h"
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
#define TIMER_INTERRUPT_DEBUGÂ Â 1
#include "ESP32TimerInterrupt.h"
#define PIN_D23Â Â Â Â Â Â Â Â Â 23Â Â Â Â // Pin D23 mapped to pin GPIO23/VSPI_MOSI of ESP32
unsigned int SWPin = PIN_D23;
#define TIMER0_INTERVAL_MSÂ Â Â Â 1
#define DEBOUNCING_INTERVAL_MSÂ Â 80
#define LOCAL_DEBUGÂ Â Â Â Â Â Â 1
// Init ESP32 timer 0
ESP32Timer ITimer0(0);
volatile unsigned long rotationTime = 0;
float RPMÂ Â Â = 0.00;
float avgRPMÂ Â = 0.00;
volatile int debounceCounter;
void IRAM_ATTR TimerHandler0()
{
 static bool started = false;
 if (!started)
 {
  started = true;
  pinMode(SWPin, INPUT_PULLUP);
 }
 if ( !digitalRead(SWPin) && (debounceCounter >= DEBOUNCING_INTERVAL_MS / TIMER0_INTERVAL_MS ) )
 {
  //min time between pulses has passed
  RPM = (float) ( 60000.0f / ( rotationTime * TIMER0_INTERVAL_MS ) );
  avgRPM = ( 2 * avgRPM + RPM) / 3,
  Serial.println("RPM = " + String(avgRPM) + ", rotationTime ms = " + String(rotationTime * TIMER0_INTERVAL_MS) );
  rotationTime = 0;
  debounceCounter = 0;
 }
 else
 {
  debounceCounter++;
 }
 if (rotationTime >= 5000)
 {
  // If idle, set RPM to 0, don't increase rotationTime
  RPM = 0;
  Serial.println("RPM = " + String(RPM) + ", rotationTime = " + String(rotationTime) );
  rotationTime = 0;
 }
 else
 {
  rotationTime++;
 }
}
void setup()
{
 Serial.begin(115200);
 while (!Serial);
 delay(100);
Â
 Serial.println("\nStarting RPM_Measure on " + String(ARDUINO_BOARD));
 // Using ESP32 => 80 / 160 / 240MHz CPU clock ,
 // For 64-bit timer counter
 // For 16-bit timer prescaler up to 1024
 // Interval in microsecs
 if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
  Serial.println("Starting ITimer0 OK, millis() = " + String(millis()));
 else
  Serial.println("Can't set ITimer0. Select another freq. or timer");
 Serial.flush();Â
}
void loop()
{
}
Thank you and stay Healthy!