cancel
Showing results for 
Search instead for 
Did you mean: 

Non blocking debug messages to UART

mosamasa
Associate II

Hi,

I'm using STM32H755 nucleo board. I'm running FREERTOS on core M7 and bare metal on M4. I have been sending debug messages through USART3. It has been working ok, but sometimes messages from different tasks are overlapping.

I want to change code such a way that debug messages are non-blocking. My plan has been using DMA and ring buffer. Finally, I would like to send debug messages from M4 core also using shared memory. 

Is this good approach or is there better way to send debug messages? Is there some example codes with this functionality? It seems that I'm not able to receive any debug messages after my kernel starts.

4 REPLIES 4
Ozone
Principal

>  It has been working ok, but sometimes messages from different tasks are overlapping.

> I want to change code such a way that debug messages are non-blocking.

The overlapping is surely coming from different tasks, and are not related to the blocking/non-blocking nature of transmission. Both things have nothing to do with each other.

What you mean is synchronisation of messages.

You could implement a message queue, with semaphores / critical sections to guard the insertion and removal of messages.

Yes, I agree that overlapping from different tasks and blocking/non-blocking messages are different things. I hope to find solution for both. DMA should solve blocking topic, but I think queue works only after kernel has started. It is fine if debug messages are blocking and overlapping (which is not possible) before kernel has started.

KnarfB
Super User

Not sure if it is compatible with FreeRTOS, but if you use DMA you could protect it by the hardware semaphore.

See Re: Using HSEM of STM32H7 ( sharing data ) - STMicroelectronics Community

hth

KnarfB

> DMA should solve blocking topic, ...

DMA only offloads the "task" of reloading the UART TDR periodically. A full UART transmission takes quite a long time compared to a core instruction. You still need to protect the DMA from getting aborted and restarted by a new send request from another FreeRTOS task. DMA does nothing to protect against this "overlap".

By the way, an alternative would be to use the UART TxE interrupt, consuming very little time/performance.