This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART close breakes whole communication

Hello 

I am writing low-power application where NRF is called from the other chip by interrupt, performs bluetooth scan and sends data back over UART. Of course, I want to close and reopen UART on every interrupt to decrease power consumption. On NRF52832 I am using SDK 15.2.0 and S132

So the problem is that after the uart initialization in main thread I am receiving interrupt, going to BLE scan and on the timeout event making app_uart_put() and app_uart_close(). In case app_uart_close() is not there - data is sent well. But when it is there I am receiving just several random (0xFE or 0xFF) bytes on other side and that is it. 

I was googling a lot and searched the forum. So here is what I already tried: 

1. Rewrite uart_init() from APP_UART_FIFO_INIT to app_uart_init(). Here is how my initialisation looks like right now 

	uint32_t					 err_code;
	app_uart_comm_params_t const comm_params =
	{
		.rx_pin_no	= RX_PIN_NUMBER,
		.tx_pin_no	= TX_PIN_NUMBER,
		.flow_control = APP_UART_FLOW_CONTROL_DISABLED,
		.use_parity = false,
		.baud_rate	= NRF_UART_BAUDRATE_115200
	};

	app_uart_buffers_t buffers;
	static uint8_t     rx_buf[UART_RX_BUF_SIZE];
	static uint8_t     tx_buf[UART_TX_BUF_SIZE];
	buffers.rx_buf      = rx_buf;
	buffers.rx_buf_size = sizeof (rx_buf);
	buffers.tx_buf      = tx_buf;
	buffers.tx_buf_size = sizeof (tx_buf);
	err_code = app_uart_init(&comm_params, &buffers, uart_event_handle, APP_IRQ_PRIORITY_HIGH);

2. Next few steps were taken from this thread. Increased UART interrupt priority to APP_IRQ_PRIORITY_HIGH.

3. Call uart_init() and app_uart_close() from main thread, there is now function in while(1) loop which checks flag status and does it from there, not from the event handler. 

4. Disable debug logs to RTT completely because apparently there is some issue with LOG and UART modules working together. 

None of those steps helped. Looking forward to hear your thoughts on this topic, for me it is quite crucial right now. Any links for the example/tutorial of UART in low-power mode would be much appreciated. Thanks!

Related