Continuous transmission based on UART sample using Nordic Connect

Good morning everyone,

I need to transmit continuously data between a central and a peripheral using a modified version of the UART example; I am working with the Zephyr-based Nordic connect SDK and with two NRF52833DK boards.

Apparently, it seemed a very easy task, but I am having a hard time making it work correctly.....

What I did was to create a dedicate thread to put messages in the uart_rx queue of the central, and I would expect these messages to be transmitted on the BLE link with the peripheral periodically. 

The code used for this is the following 

void dataProducerThread() 
{	


	while(true)
	{
		struct uart_data_t *tx = k_malloc(sizeof(*tx));
		tx->data[0] = 'H';
		tx->data[1] = 'e';
		tx->data[2] = 'l';
		tx->data[3] = 'l';
		tx->data[4] = 'o';
		tx->data[6] = 'f';
		tx->data[7] = 'r';
		tx->data[8] = 'o';
		tx->data[9] = 'm';
		tx->data[10] = 'c';
		tx->data[11] = 'e';
		tx->data[12] = 'n';
		tx->data[13] = 't';
		tx->data[14] = 'r';
		tx->data[15] = 'a';
		tx->data[16] = 'l';
		tx->len = sizeof(tx->data);
		LOG_INF("Hello from producer thread ");

		k_fifo_put(&fifo_uart_rx_data, tx); 
		k_free(tx);
		k_sleep(K_MSEC(1000));
	}


}


K_THREAD_DEFINE(dataProducerThreadID, 1024, dataProducerThread, NULL, NULL, NULL, 7, 0, 0);

essentially, I am doing here what is done in the existing central_uart example whenever something is written on the keyboard and transmitted to the serial port.

The problem I have is that once in a while the message is correctly transmitted to the peripheral, but at a given point, after a few (3-4) exhchanges, the central produces the following crash

00:00:05.132,751] .[1;31m<err> os: ***** BUS FAULT *****.[0m
[00:00:05.132,781] .[1;31m<err> os:   Precise data bus error.[0m
[00:00:05.132,781] .[1;31m<err> os:   BFAR Address: 0x100024.[0m
[00:00:05.132,812] .[1;31m<err> os: r0/a1:  0x00100024  r1/a2:  0x20007dfc  r2/a3:  0x20007e04.[0m
[00:00:05.132,843] .[1;31m<err> os: r3/a4:  0x00000040 r12/ip:  0x00011819 r14/lr:  0x00025c31.[0m
[00:00:05.132,843] .[1;31m<err> os:  xpsr:  0x21000000.[0m
[00:00:05.132,873] .[1;31m<err> os: Faulting instruction address (r15/pc): 0x000260e0.[0m
[00:00:05.132,904] .[1;31m<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0.[0m
[00:00:05.132,965] .[1;31m<err> os: Current thread: 0x20002138 (unknown).[0m
[00:00:05.221,679] .[1;31m<err> fatal_error: Resetting system.[0m

Now, I do not fully understand the meaning of this, but it seems to indicate that I am doing something wrong when writing in the fifo queue.....


So, my question is: how can I have a continuous transmission of ble packets between the two boards? 

Thanks in advance!

Related