AT commang gsm with FreeRTOS

I use gsm with stm32 , I send ِAT commands to the GSM module via UART, I normally do so using polling mode, but with FreeRTOS I don’t know what is the best approach for sending AT commands

Thanks for the helpers

It is very much dependent on the use case. What is the CPU load of the system you are developing, and what is the expected network throughput. If both the CPU load and network throughput are low then a simple polling UART driver is probably best, just because it is easy to write, test and maintain. At the other extreme you might want to be using a DMA to push as much data through the UART as you can with minimum CPU load. I suspect you will fit somewhere in between these two extremes though.

The thing that poses a problem to me is that after sending every command I check the response of the GSM module, the polling mode is easy and simple but it didn’t work for me!
I don’t know the reason, I think because polling mode using systick of time out ,that might conflict with rtos

I’m not sure I’m completely following, but if you want to get time from the RTOS you can call xTaskGetTickCount().

Because HAL drivers use Systick ST Cube provides a FreeRTOS configuration using another TIMer (e.g. TIM2) as ticker. So when using a cube generated project there should be no interference between HAL and FreeRTOS.
Using polling UART driver mode might be ok when done in a appropriately prioritized task without affecting other tasks (with higher prio) runtime behavior.
But depending on the higher prio tasks behavior chances are that you miss reading RX data in time and loose some bytes.
The better and robust way in multitasking applications is using an interrupt driven driver. at least for RX. For a rather slow UART interface it’s ok to omit a more complicated DMA based approach and just let an interrupt kick in for every RXNE event. Put the RX data byte e.g in a FreeRTOS streambuffer waited for in the associated (driver) task, process the data there and you will be fine. Sending data at least in your case with AT commands can be done the most simple way without interrupts I.e. send a byte, poll for TXE … until done.