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

app_uart_get more than 1 byte

Hi,

I'm using app_uart for communication between different mcu. I can send more than 1 byte like "0x3917015623"  through  changing tx_buffer[0] to tx_buffer[5]. Unfortunately i couldn't recieve the slave devicess message "0x2917013607". I can only get the first byte "0x07". My configuration are the same as uart example. How can i recieve all the message ?. I tried to use serial library but i couldn't initialize. (It gave ERROR 6 NRF_ERROR_NOT_SUPPORTED).

Slave device is sending me a message every second. And i'm calling app_uart_get function every 500 miliseconds.

Here is my uart init;

void uart_error_handle(app_uart_evt_t * p_event)
{
    if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_communication);
    }
    else if (p_event->evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_code);
    }    
}

void uart_init(void)
{
    uint32_t err_code;
    const app_uart_comm_params_t comm_params =
        {
            RX_PIN_NUMBER,
            TX_PIN_NUMBER,
            RTS_PIN_NUMBER,
            CTS_PIN_NUMBER,
            UART_HWFC,
            false,
  #if defined (UART_PRESENT)
            NRF_UART_BAUDRATE_115200
  #else
            NRF_UARTE_BAUDRATE_9600
  #endif
        };
//    const app_uart_buffers_t m_buffers =
//      {
//        &rx_buffer_s,
//        sizeof(rx_buffer_s),
//        &tx_buffer_s,
//        sizeof(tx_buffer_s)
//      }
      APP_UART_FIFO_INIT(&comm_params,
                           UART_RX_BUF_SIZE,
                           UART_TX_BUF_SIZE,
                           uart_error_handle,
                           APP_IRQ_PRIORITY_LOWEST,
                           err_code);

      APP_ERROR_CHECK(err_code);
//      err_code = app_uart_init(&comm_params, &m_buffers, uart_error_handle, APP_IRQ_PRIORITY_LOW);
//      APP_ERROR_CHECK(err_code);
  
}

Regards,

  • I solved the message order problem. It should be  an array with 5 elements, Now i have another problem. I can communicate between two nrf board correctly there is no problem for now. There is a problem with receiving data from other mcu. I can send data to PIC16f1788 but i can't receive correct data. There is no problem between nrf to nrf  or pic to pic and also nrf to pic. But when nrf is receiver and pic is transmitter, nrf is not taking correct data. The signal must be same on Rx and Tx.

    Here is the signals on PIC16F1788 Tx pin :

    Here is the nrf Rx pin :

  • This is without HWFC right? The waveforms look completly identical, except the TX line being initially low on the first capture, but high on the second. If this is measured at the TX pin of the PIC and the RX pin of the NRF, then the captures should be identical as you say. You do not get any UART events on the nRF side when the PIC is transmitting?

  • Hi, Bjorn !

    This is without HWFC right?

    Yes, HWFC is disabled. I am not in the office until Monday but last time when i tested code, i set a breakpoint on nrf_serial_read function. It returns error code 13. I think it means Timed out error. I couldn't find solution for that. And secondly, 2 leds connected to rx and tx pin on nrf. These 2 leds are turned off when no transmitting status. When message comes on tx or rx pins, related led blinks a short time. Communication between nrf to nrf works fine, leds are blinking while transmitting. When i unplug the transmitter nrf (slave) and plug the other slave (PIC16F1788), the led on receiver line stays turned on. I can give more information on Monday.

  • Yes, error code 13( decimal ) is NRF_ERROR_TIMEOUT. 

    Ok, will wait for the update from you. 

    Best regards

    Bjørn

  • I pretty solved the rx pin problem. I started to use the SN65HVD72 IC instead of MAX485.  I can receive the message but NRF_ERROR_TIMEOUT error very offen happens. I changed nrf_serial_read function's time out parameters but didn't helped. My transmitter send a byte 0 to 255. Here is the outputs of receiver side  (I print first return code in decimal, secondly received data):

    <info> app: Recieved error : 0

    <info> app: Recieved data : 54

    <info> app: Recieved error : 0

    <info> app: Recieved data : 55

    <info> app: Recieved error : 0

    <info> app: Recieved data : 56

    <info> app: Recieved error : 0

    <info> app: Recieved data : 57

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 60

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 66

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 70

    <info> app: Recieved error : 0

    <info> app: Recieved data : 71

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 74

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 78

    <info> app: Recieved error : 0

    <info> app: Recieved data : 79

    <info> app: Recieved error : 0

    <info> app: Recieved data : 80

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 86

    <info> app: Recieved error : 0

    <info> app: Recieved data : 87

    <info> app: Recieved error : 0

    <info> app: Recieved data : 88

    <info> app: Recieved error : 0

    <info> app: Recieved data : 89

    <info> app: Recieved error : 0

    <info> app: Recieved data : 90

    <info> app: Recieved error : 0

    <info> app: Recieved data : 91

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 97

    <info> app: Recieved error : 0

    <info> app: Recieved data : 98

    <info> app: Recieved error : 0

    <info> app: Recieved data : 99

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 102

    <info> app: Recieved error : 13

    <info> app: Recieved data : 253

    <info> app: Recieved error : 0

    <info> app: Recieved data : 104

    <info> app: Recieved error : 0

    <info> app: Recieved data : 105

Related