Hello,
Ake's mention of the sei instruction is incorrect, as this instruction disables interrupts. The instruction is quite unnecessary within the ISR, since further interrupts are automatically disabled, but it will do no harm.
I have difficulty in understanding the intent of your code, partly because I do not speak Spanish. However, it does seem that there may be some unorthodox features, concerning program flow.
The kbdetect ISR does appear rather complex, and includes a delay loop. Where possible, ISR code should be simple so that it may exit quickly.
The int_irq ISR contains a STOP instruction. Interrupts are normally globally disabled within the ISR, however, the STOP instruction will automatically re-enable interrupts, which more than likely will be problematic after wake-up occurs.
I would usually expect main to be a loop in itself, so that its functions continually repeat. However, with the following code present -
stop
bra *
this would mean that the stop instruction could only execute once, before entering an infinite loop. If COP timeout is not disabled, eventually a COP reset would occur.
My expectation might have been that the STOP instruction would be executed once during each cycle of the main loop, and that STOP should not occur within any ISR.
Regards,
Mac