0
\$\begingroup\$

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.

Error and code

toolic
10.8k11 gold badges31 silver badges35 bronze badges
asked Dec 20, 2023 at 14:11
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

answered Dec 20, 2023 at 14:23
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.