Simple Maths results in Guru Meditation Error
Posted: Fri Oct 15, 2021 8:24 pm
Hi,
I am working with the NodeMCU ESP32. I have a coin sensor built from two copper plates that detect when a coin rolls down the chute. I am using the interrupt function to detect the coin. It works well with the Arduino Uno R3, but when connected to the NodeMCU ESP32, a simple calculation in my function results in the following error:
It goes on to show me the Core 1 register dump, and then says:
Here is the breakdown of the code I am using:
1) I set up the interrupt on GPIO 17:
2) The Interrupt_CoinDeposit() calls another function:
3) The Enqueue Coin function is supposed to check if one second has passed since the first time the coin struck the copper plates. This is to avoid the same coin being counted multiple times due to contact bounce:
Notes: is a function that returns the time, in type float, that the NodeMCU has been running. is another float that has been initiated in the setup() function.
My code runs into issues when I reach the line. I have tested this by using print lines as well as commenting out sections of the code. This code works with the Arduino Uno R3 but I can't seem to figure out why I am getting a segmentation fault with the ESP32.
I am working with the NodeMCU ESP32. I have a coin sensor built from two copper plates that detect when a coin rolls down the chute. I am using the interrupt function to detect the coin. It works well with the Arduino Uno R3, but when connected to the NodeMCU ESP32, a simple calculation in my function results in the following error:
Code: Select all
Guru Meditation Error: Core 1 panic'ed (Coprocessor exception)
Code: Select all
Core 1 was running in ISR context
1) I set up the interrupt on GPIO 17:
Code: Select all
attachInterrupt( digitalPinToInterrupt(INPUT_PIN_COIN), Interrupt_CoinDeposit, FALLING );
Code: Select all
void IRAM_ATTR Interrupt_CoinDeposit()
{
g_crOSCore.EnqueueCoin();
}
Code: Select all
bool CCrowboxCore::EnqueueCoin()
{
//cros_time_t is a typedef of float
cros_time_t n = GetUptimeSeconds();
Serial.println(n);
cros_time_t m = m_uptimeLastCoinDetected;
Serial.println(m);
cros_time_t x = n - m;
Serial.println(x);
if (x < 1.0) {
return false;
}
m_numEnqueuedDeposits++;
m_uptimeLastCoinDetected = GetUptimeSeconds();
return true;
}
Code: Select all
GetUptimeSeconds();
Code: Select all
m_uptimeLastCoinDetected
My code runs into issues when I reach the
Code: Select all
x = n - m