ESP32 : Inter task communication using FreeRTOS Queues

In the previous post we have seen how to create task , in this post we will see how to use queues to share data between two tasks.

source : http://www.freertos.org

We are creating two tasks, one task will produce the data and other will consume the data.

The producer task will produce a value every second and adds this value at the end of the queue (element addition will be done at the tail)

xQueueSend(queue,pointer to the value, time to wait if the queue if full)

The consumer task will read a value from queue head every 500 ms, if there is no value it will wait for 1 second

xQueueReceive(queue,value receiver,time to wait if the queue is empty)

app_main will create the queue and starts the tasks

 

For more on FreeRTOS queues you can read this writeup

 

Add a Comment

Your email address will not be published. Required fields are marked *