Hi Jacek,
well, it's better to disable interrupts in firmware, just comment out EnableInterrupts; codeline or type in DisableInterrupts;
But, this might not be much of help since you are using RTOS which uses the interrupts a lot.
Now, looking at the screenshot, the code stucked in RAM. So, not sure if it caused by RTOS itself.
We think that the issue is with pointers and/or addressing. For example, the program is pointed to an _far address (RPAGE, PPAGE or GPAGE), but the pointer value is missing high byte.
The Illegal_BP is a typical SW thing. It means the debugger lost (MCU behavior is different from behavior which debugger expects).
Typical root cause is unexpected interrupt or BDM communication is down. This is usually generated by the following causes:
_ unmapped interrupt vectors
_ watchdogs
_ jump, read or write to unimplemented addresses (could be due to inappropriate libraries).
_ stack overflow
Regards,
iggi