# UART communication

**URL:** <https://forums.freertos.org/t/uart-communication/7377>\
**Category:** Kernel\
**Created:** [August 18, 2018, 8:31am UTC](https://forums.freertos.org/t/uart-communication/7377 "2018-08-18T08:31:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 18, 2018, 8:31am UTC](https://forums.freertos.org/t/uart-communication/7377/1 "2018-08-18T08:31:43Z")

</div>

**[ose](https://sourceforge.net/u/ose/)** wrote on [Saturday, August 18, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/269cc6f2/#84d5):

Hi, i am using the Arduino Uno with the ATMEGA328p microcontroller.  
I wanna implement UART communication and i am not sure of the process when using freertos.  
Doing uart communcation without freertos is no problem for me but with Freertos i dont know what functions to use.

I have done some reading and i went through the freertos pdfs and saw some examples but i am not very clear on them.

Please it would be great if i got some steps on how to go about it.

Thank you

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [August 18, 2018, 9:14pm UTC](https://forums.freertos.org/t/uart-communication/7377/2 "2018-08-18T21:14:11Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Saturday, August 18, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/269cc6f2/#84d5/e031):

I don’t know how the UART works on the Arduino, but I suspect it will be  
a simple uart write function that is not thread safe. If you have  
access to the registers and interrupt service routines then you can  
create a driver that uses FreeRTOS primitives and therefore allows  
readers and writers to block - otherwise you will just have to put a  
wrapper around the uart functions to prevent context switches while they  
are being used - for example wrap in a  
vTaskSuspendAll()/xTaskResumeAll() pair. Ideally just have a single  
thread that accesses the UART, and if other threads need to access it to  
then have those other threads send their messages to the task that is  
allowed to access the UART and have that task actually send them out.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 20, 2018, 12:48pm UTC](https://forums.freertos.org/t/uart-communication/7377/3 "2018-08-20T12:48:16Z")

</div>

**[ose](https://sourceforge.net/u/ose/)** wrote on [Monday, August 20, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/269cc6f2/#44a2):

I applied your suggestions and it worked .Thanks
