Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By cal
#18236 Moin,

I am able to send the esp8266 a serial break via serial line and detect it in an interrupt handler.
I don't want to "break" the cpu in this uart interrupt handler but I want it getting stopped
when it returns to user code.
A kind of pending "break" that gets triggered when returning from the interrupt handler.

I could use the stepping support but that feels wrong.
Should I set a breakpoint on the "interrupt return address"?
Or should I "break" in the interrupt code and "return" from that to get into user code using debugger means?

"user code" should mean code executed on int level 0.

I have the feeling that I miss something or that I expect too much support from the cpu.

Any ideas or opinions?

Cal
User avatar
By joostn
#18243 The proper way to handle such a thing is via an event queue. The interrupt handler adds an item in the event queue, the main function runs an event loop which continuously checks for new items in the queue.

The ESP already runs such an event loop by default. In your user_main you should set up an event handler via system_os_task(), and in your interrupt you can post an item to the queue via system_os_post(). There can be at most 3 event queues (identified by an integer referred to as 'prio').
User avatar
By cal
#18244 Thanks for your answer.

I should have been more specific in my post.

I want to do the break/stop on cpu/ debugger level not on os/firmware level.

Like calling the xtensa BREAK/BREAK.N cpu opcode but only getting effective when interrupt level is lowered
after return from interrupt handler.

Cal