I am craeting two task and A ,B and i want to send data on same UART and i am using preemtive scheduling with 1ms systick below is my code i have written
The first part of the answer is that very likely UART_Write is NOT designed to be RTOS aware, and thus not suitable. It likely also “spin-waits” as it is sending, and thus isn’t really appropriate for use in an RTOS, even if you added the sycronization needed to make it uable in an RTOS.
Studying a bit to understand those questions will help you emensly to answer the question you are asking.
It would help to know which assert was triggered, but a common one is due to not assigning the interrupt a valid priority. They often default to a non-suitable priority.
Why not create 3 tasks.
TAsk A/B to write to a Queue
Tasks 3 that reads the queue and sent to a UART…
Unless you want to have some order, but then it sounds like you are doign something wrong…
If the write to the parts is using an interrupt based driver, then you don’t really need a third task to do the operations, but they can be done at the task level.
There will need to be a Semaphore or Mutex to block access while the operation is in progress (it needs to be a semaphore if it will be cleared by an ISR).
If the ISR asserted in the xSemaphoreGiveFromISR, as reported, my guess is that the interrupt priority of the ISR was never set right (and on many machines it defaults to being just too high). That, or the file with the ISR isn’t getting the right handle for the Semaphore.
I have rarely found a uart driver from a vendor that worked the way I wanted, as they almost always take a buffer that needs to be maintained with the data until the sending is complete, and then you can give them another buffer. I tend to write my own that stores the data to send into a Queue or Streambuffer, and that is pulled off in an ISR. The sending end of the Queue/Streambuffer is guarded with a Mutex so tasks can fill the buffer with a full message, at which point they give it up.