LIBUARTE TRANSMITTING ONLY ONE BYTE.

I am using NRF52833 in my project and I have my NRF module connected to 2 other microcontrollers on UART peripherals. The details are mentioned as below:-

1) NRF52833 connected to MCU A- NORMAL UART

   RX pin of nrf- P0.29

   TX pin of nrf- P0.28

2) NRF52833 connected to MCU B -- LIBUARTE

   RX pin of nrf- P0.30

   TX pin of nrf- P0.31.

I have successfully configured connection to MCU and I am able to transmit data from NRF to MCU A and receive data on NRF from MCU A.

I have also successfully configured connection to MCU and I am able to transmit data from NRF to MCU B and receive data on NRF from MCU B. The problem with LIBUARTE here is that I want to transmit an array of hex data.

char array3[5] = { 0x73, 0x01, 0x0a, 0x0d};




void send_data(void)
{
  ret_code_t err_code;

    err_code = nrf_libuarte_async_tx(&libuarte, (uint8_t *)array3, sizeof(array3));
    APP_ERROR_CHECK(err_code);
    vTaskDelay(5000);
}

char *string2;
static uint8_t buffer[256];

void libuart_event_handler(void *context, nrf_libuarte_async_evt_t *p_evt) {
    static uint8_t index;
    char *str;
  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: {
      NRF_LOG_ERROR("LIBUARTE ERROR");
      break;
    }
    case NRF_LIBUARTE_ASYNC_EVT_RX_DATA: {
     // Receive complete
     memset(buffer,'0',sizeof(buffer));
      memcpy(buffer, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
      int data_length = p_evt->data.rxtx.length;
      str = malloc(strlen(buffer) + 1);
      strcpy(str,buffer); 
      NRF_LOG_INFO("%s",str);     
      nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
      break;
    }
    case NRF_LIBUARTE_ASYNC_EVT_TX_DONE: {
      // Transmit complete

      break;
    }
  }
}

I am able to transmit only 1st byte 0x73. Libuarte doesn't send the rest bytes. What might be the issue? Is something wrong with my code? 

Thanks & Regards,

Snehal.

Parents Reply Children
No Data
Related