Hi there,
I'm using nrf52840 DK and Custom board, SDK 17.0.2, Segger Embedded Studio(SES v5.20
my issue is when we send/TX data through UART "static uint8_t text[] = {0x01, 0x03, 0x00, 0xdf, 0x53, 0x00, 0x56, 0x76};" in loopback we don't received the 0x00 data like in uart0 buffer we received { 0xdf, 0x53,0x56, 0x76} kind of data. we checked the data by debugging the code
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "nrf_libuarte_async.h"
#include "nrf_drv_clock.h"
#include <bsp.h>
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "nrf_queue.h"
#define pin_rx0 26//NRF_GPIO_PIN_MAP(0, 26)
#define pin_tx0 27//NRF_GPIO_PIN_MAP(0, 27)
#define pin_rx1 NRF_GPIO_PIN_MAP(1, 13)
#define pin_tx1 NRF_GPIO_PIN_MAP(1, 14)
NRF_LIBUARTE_ASYNC_DEFINE(uarte0, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
NRF_LIBUARTE_ASYNC_DEFINE(uarte1, 1, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
static uint8_t text[] = {0x01, 0x03, 0x00, 0xdf, 0x53, 0x00, 0x56, 0x76};
static uint8_t text_size = sizeof(text);
static uint8_t text1[] = "UART111111 example started.\r\n";
static uint8_t text_size1 = sizeof(text1);
static volatile bool m_loopback_phase;
typedef struct {
uint8_t * p_data;
uint32_t length;
} buffer_t;
NRF_QUEUE_DEF(buffer_t, m_buf_queue, 10, NRF_QUEUE_MODE_NO_OVERFLOW);
uint8_t uart0_array[256] ={0};
uint8_t uart1_array[256]={0};
void uart0_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
{
nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
ret_code_t ret;
switch (p_evt->type)
{
case NRF_LIBUARTE_ASYNC_EVT_ERROR:
//bsp_board_led_invert(0);
break;
case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
//memset(uart0_array,0,sizeof(uart0_array));
//memcpy(uart0_array,p_evt->data.rxtx.p_data,p_evt->data.rxtx.length);
strcat(uart0_array,p_evt->data.rxtx.p_data);
break;
case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
break;
default:
break;
}
}
void uart1_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
{
nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
ret_code_t ret;
switch (p_evt->type)
{
case NRF_LIBUARTE_ASYNC_EVT_ERROR:
//bsp_board_led_invert(0);
break;
case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
//memset(uart1_array,0,sizeof(uart1_array));
//memcpy(uart1_array,p_evt->data.rxtx.p_data,p_evt->data.rxtx.length);
strcat(uart1_array,p_evt->data.rxtx.p_data);
break;
case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
break;
default:
break;
}
}
/**
* @brief Function for main application entry.
*/
int main(void)
{
ret_code_t err_code = NRF_LOG_INIT(app_timer_cnt_get);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEFAULT_BACKENDS_INIT();
NRF_LOG_INFO("PROGRAM STARTED");
int32_t reset_reason = NRF_POWER->RESETREAS;
NRF_LOG_INFO("Reset reason = 0x%08x.\n", reset_reason);
NRF_POWER->RESETREAS = NRF_POWER->RESETREAS;
bsp_board_init(BSP_INIT_LEDS);
ret_code_t ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
nrf_drv_clock_lfclk_request(NULL);
nrf_libuarte_async_config_t nrf_libuarte0_async_config = {
.tx_pin = pin_tx0,//TX_PIN_NUMBER,
.rx_pin = pin_rx0,//RX_PIN_NUMBER,
.baudrate = NRF_UARTE_BAUDRATE_115200,
.parity = NRF_UARTE_PARITY_EXCLUDED,
.hwfc = NRF_UARTE_HWFC_DISABLED,
.timeout_us = 100,
.int_prio = APP_IRQ_PRIORITY_LOW
};
nrf_libuarte_async_config_t nrf_libuarte1_async_config = {
.tx_pin = pin_tx1,//TX_PIN_NUMBER,
.rx_pin = pin_rx1,//RX_PIN_NUMBER,
.baudrate = NRF_UARTE_BAUDRATE_9600,
.parity = NRF_UARTE_PARITY_EXCLUDED,
.hwfc = NRF_UARTE_HWFC_DISABLED,
.timeout_us = 100,
.int_prio = APP_IRQ_PRIORITY_LOW
};
err_code = nrf_libuarte_async_init(&uarte0, &nrf_libuarte0_async_config, uart0_event_handler, (void *)&uarte0);
NRF_LOG_INFO("err_code: %u",err_code);
APP_ERROR_CHECK(err_code);
err_code = nrf_libuarte_async_init(&uarte1, &nrf_libuarte1_async_config, uart1_event_handler, (void *)&uarte1);
APP_ERROR_CHECK(err_code);
nrf_libuarte_async_enable(&uarte0);
nrf_libuarte_async_enable(&uarte1);
err_code = nrf_libuarte_async_tx(&uarte0, text, text_size);
APP_ERROR_CHECK(err_code);
err_code = nrf_libuarte_async_tx(&uarte1, text, text_size);
APP_ERROR_CHECK(err_code);
while (true)
{
NRF_LOG_FLUSH();
}
}
/** @} */
please help me out
thanks in advace
himanshu