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

SDK17.0.2 LIBUART PROBLEM

Hi, 

I setted up the LIBUARTE on my custom board...

NRF52833,SDK17.0.2,With Softdevice enabled

CODE:

-----------------------------------

NRF_LIBUARTE_ASYNC_DEFINE(modem_libuarte, 0, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

nrf_libuarte_async_config_t nrf_libuarte_async_config_modem;

typedef struct {
uint8_t * p_data;
uint32_t length;
} buffer_t_modem;

NRF_QUEUE_DEF(buffer_t_modem, m_buf_queue_modem, 10, NRF_QUEUE_MODE_NO_OVERFLOW);

void uart_event_handler_modem(void * context, nrf_libuarte_async_evt_t * p_evt)
{
nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
ret_code_t ret;
unsigned char mone_char;

switch (p_evt->type)
{
case NRF_LIBUARTE_ASYNC_EVT_ERROR:
//bsp_board_led_invert(0);
break;
case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
uart_rx_timeout = UART_RX_TIMEOUT;
for (mone_char=0;mone_char<p_evt->data.rxtx.length;mone_char++)
{
rec_char = p_evt->data.rxtx.p_data[mone_char];
modem_rx_interrupt(rec_char);
}
break;
case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
//nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
if (!nrf_queue_is_empty(&m_buf_queue_modem))
{
buffer_t_modem buf;
ret = nrf_queue_pop(&m_buf_queue_modem, &buf);
APP_ERROR_CHECK(ret);
UNUSED_RETURN_VALUE(nrf_libuarte_async_tx(p_libuarte, buf.p_data, buf.length));
}
break;
default:
break;
}
}

void uart_modem_init(void)
{
ret_code_t err_code;

nrf_libuarte_async_config_modem.tx_pin = LEG_GSM_RX_IN;
nrf_libuarte_async_config_modem.rx_pin = LEG_GSM_TX_OUT;
nrf_libuarte_async_config_modem.cts_pin = NULL;
nrf_libuarte_async_config_modem.rts_pin = NULL;
nrf_libuarte_async_config_modem.baudrate = NRF_UARTE_BAUDRATE_115200;
nrf_libuarte_async_config_modem.parity = NRF_UARTE_PARITY_EXCLUDED;
nrf_libuarte_async_config_modem.hwfc = NRF_UARTE_HWFC_DISABLED;
nrf_libuarte_async_config_modem.timeout_us = 100;
nrf_libuarte_async_config_modem.int_prio = APP_IRQ_PRIORITY_HIGH;

err_code = nrf_libuarte_async_init(&modem_libuarte, &nrf_libuarte_async_config_modem, uart_event_handler_modem, (void *)&modem_libuarte);
APP_ERROR_CHECK(err_code);

nrf_libuarte_async_enable(&modem_libuarte);
}

void uart_modem_tx(unsigned char *x) // Which called every 1s....for testing
{
ret_code_t err_code;

// err_code = nrf_libuarte_async_tx(&modem_libuarte, x, strlen((char const *)x));
err_code = nrf_libuarte_async_tx(&modem_libuarte,"12345",5);
APP_ERROR_CHECK(err_code);
}

And what i see all the time is: (btw: i get the NRF_LIBUARTE_ASYNC_EVT_TX_DONE event)

It doesn't matter if i change to TIMER or RTC in NRF_LIBUARTE_ASYNC_DEFINE....i tried many options but the transmission is  all the time is like this.

Any idea why?

Btw: After the uarte module will work, i need to set up 2 uarte ! If you got any example of setting 2 uartse on SDK17.0.2 with app_timer it will be great !

Also , I can't run the LIBUARTE example on my custom board directly. (the RTC is LP external crystal with 32.768K)

B.r,

Yuval.

  • Found the problem !

    nrf_libuarte_async_tx(&modem_libuarte,"12345",5);     the "12345" is cleared on exit the function.....i needed to use static memory instead

  • Hi,

    nrf_libuarte_async_tx() takes a pointer to the data buffer, which is assigned to the UARTE peripheral to get the the data directly from RAM (through EasyDMA). Since you are passing the string directly to the function, and not through a pointer, this string will be stored in flash, where the UARTE peripheral have no way to access it. To fix this, you should declare an array first with the data, which you pass to the function:

    uint8_t uart_string[] = "12345";
    err_code = nrf_libuarte_async_tx(&libuarte,uart_string,5);
    APP_ERROR_CHECK(err_code);

    Using two instances of libUARTE should be straightforward, just initialize and configure both instances as shown in the libUARTE example. You need to make sure to either use different resources for each instance (RTC/TIMER), or use the app_timer option.

    Best regards,
    Jørgen

Related