Hi,
I'm working on an S32K platform using FreeRTOS. I have two tasks (UartTask1 and UartTask2) that frequently call debug_log() to send messages over UART.
Logging structure:
debug_log() formats the message and enqueues it into a FreeRTOS queue.
A dedicated uart_log_task() dequeues and sends each message using Lpuart_Uart_Ip_AsyncSend().
UART TX completion is confirmed using a callback that sets a uart_tx_done flag.
A small vTaskDelay() is added after UART transmission in the log task — no queue overflow is observed.
Issue:
Every time UART starts sending, only a few characters are printed or sometimes garbage, and then the system hits a hard fault.
This happens consistently during UART transmission, not before.
Key finding:
When I isolate UART and test it outside of the logging system (no queue, no multiple tasks), it works fine. So the UART driver itself seems okay.
Question:
What could be causing this crash in the multitask logging setup?
Is it possible that a shared/static buffer (like tx_data) is getting overwritten or accessed before TX completes?
Are there specific precautions for using Lpuart_Uart_Ip_AsyncSend() with FreeRTOS and multiple tasks?
Any help or suggestions would be greatly appreciated.
Thanks in advance!
I have attached snippet code and lpuart config.