0

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?

Mopiju
  • 1

2 Answers2

0

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.

Lundin
  • 195,001
  • 40
  • 254
  • 396
  • Thank you, I have found a better solution in the meantime. I'll just create a new thread which fetches the RS232 data every 100ms. Thanks anyway for the quick answer!! – Mopiju May 11 '22 at 12:44
0

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://learn.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.