I am using esp8266 to calculate the rpm using hall 3144 sensor, and while doing so there is an issue arises in code.
void exti_callback()
{
Serial.println("working");
}
void setup() {
pinMode(D1,INPUT);
attachInterrupt(digitalPinToInterrupt(D1),exti_callback,FALLING);
Serial.begin(115200);
}
void loop() {
Serial.println("Not working");
}
upon further investigation i understand that this specific line "attachInterrupt(digitalPinToInterrupt(D1),exti_callback,FALLING);" of code is giving me error. Earlier i was using D2 pin and was still facing the same error so i thought i am using wrong pin to get the interrupt so i change that pin to pin D1 but same error still persists. How did i know that this line is giving me error because if i comment out this line, whole code works perfectly, and void loop () also starts to work fine then.
I have even tried using different baud rate, different upload rate but the issue persists. I have even change the USB cable, USB port and what not but still error came. This is the error. load 0x4010f000, len 3424, room 16 tail 0 chksum 0x2e load 0x3fff20b8, len 40, room 8 tail 0 chksum 0x2b csum 0x2b v00041f10 ~ld ⸮⸮⸮⸮o쒜p⸮⸮n|⸮l⸮⸮$`b⸮⸮|r⸮$⸮o⸮⸮o⸮ ets Jan 8 2013,rst cause:2, boot mode:(3,6)
this same error is keep getting generated again and again. Kindly help me resolving this issue. I'm stuck.
1 Answer 1
The rule number 1 of using interrupts is to not print anything in there.
That may sound weird without explanation.
But if you don't know if some mystery function provided to you is re-entrant or callable from interrupt context, you cannot call it.
Another mistake is to enable the interrupts that print to UART before you initialize the UART.
Try blinking a LED from interrupts first. Or incrementing a (volatile) variable which you print from main context.
Explore related questions
See similar questions with these tags.