Home > Software design >  tx_semaphore inside a Interrupt
tx_semaphore inside a Interrupt

Time:05-12

I want to read out RS232 data periodically. I have created an interrupt for this purpose. However, my RS232 functions need semaphores. I found out that I cannot execute a TX(Thread X) function in the interrupt. What do I have to do to make my TX function work inside the interrupt?

CodePudding user response:

If your RTOS provides a way to do it, then use that. If not, then here's some other options:

There's also a very bad idea/last resort, and that is to toggle the global interrupt mask.

CodePudding user response:

First, make sure you are calling _tx_thread_context_save and _tx_thread_context_restore at the beginning and end of your ISR, respectively. See here for more information: https://docs.microsoft.com/en-us/azure/rtos/threadx/chapter3#isr-template Second, you cannot create a semaphore in an interrupt, so make sure you create it elsewhere.

  • Related