UART rx recieved and send back with call back function will happen fatal error

Hi

     I use nRF7002 with SDK v2.52, try to connect external MCU and use uart call back function, to recieved and send bcak the recieved data, It will happen fatal error and hang up, why this issue happen?below is code for uart.please give suggestion for this issue, Thanks.

fatal error

const struct device *uart= DEVICE_DT_GET(DT_NODELABEL(uart2));
struct uart_config uart_cfg = {
	.baudrate = 460800,
	.parity = UART_CFG_PARITY_NONE,
	.stop_bits = UART_CFG_STOP_BITS_1,
	.flow_ctrl = UART_CFG_FLOW_CTRL_NONE,
	.data_bits = UART_CFG_DATA_BITS_8,
};

static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data)
{
	int ret;
	switch (evt->type) {
	case UART_RX_RDY:
		if((evt->data.rx.len) == 8)
		{
			for (uint8_t i = 0; i <RECEIVE_BUFF_SIZE; i++)
			{
				tx_buf[i] = rx_buf[i];
			}
			uart_tx(dev, tx_buf, sizeof(tx_buf), SYS_FOREVER_MS);
			uartTx_flag = 1;
			uartreadcompare_flag = 1;
		}
		break;
	case UART_RX_DISABLED:
		uart_rx_enable(dev ,rx_buf,sizeof rx_buf,RECEIVE_TIMEOUT);
		break;
		
	default:
		break;
	}
}

main()
{
	if (!device_is_ready(uart))
	{
		printk("UART device not ready\r\n");
		return 1 ;
	}
	ret = uart_callback_set(uart, uart_cb, NULL);
	if (ret) 
	{
		return 1;
	}

	ret = uart_tx(uart, tx_buf, sizeof(tx_buf), SYS_FOREVER_MS);
	if (ret) 
	{
		return 1;
	}

	ret = uart_rx_enable(uart ,rx_buf,sizeof rx_buf,RECEIVE_TIMEOUT);
	if (ret)
	{
		return 1;
	}	
}

Best Regards

    Tina

Related