<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NRF52 Uart to Ble Bridge</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62655/nrf52-uart-to-ble-bridge</link><description>Hi! 
 I&amp;#39;m trying to transfer data from UART to BLE in NRF52810. NRF52810 connects MSP430 controller via UART, MSP430 sends packet of 16 bytes lenght every 2ms (500 times in a second). UART baud rate is 460800 (NRF is uses 0x075F7000 constant). NRF52810</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 Jun 2020 14:53:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62655/nrf52-uart-to-ble-bridge" /><item><title>RE: NRF52 Uart to Ble Bridge</title><link>https://devzone.nordicsemi.com/thread/255316?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 14:53:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f6f6a59-c78c-451d-a362-365a03c45611</guid><dc:creator>Mike Anti</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_init(void)
{
    uint32_t                     err_code;
    app_uart_comm_params_t const comm_params =
    {

        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = 12,
        .cts_pin_no   = 10, 
        .flow_control = APP_UART_FLOW_CONTROL_ENABLED,
        .use_parity   = false,
        .baud_rate    =  NRF_UART_BAUDRATE_460800
    };

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_HIGHEST,
                       err_code);
    
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{

    uart_init();
    // some other init
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();

    int err_code = app_timer_create(&amp;amp;timer_id, APP_TIMER_MODE_REPEATED , &amp;amp;LedTimerHandler);
    if (err_code){
      //printf(&amp;quot;\napp_timer_create ERROR! %d\n\n&amp;quot;, err_code);
    }
    err_code = app_timer_start(timer_id, 65,NULL);
    if (err_code){
      //printf(&amp;quot;\napp_timer_start ERROR! %d\n\n&amp;quot;, err_code);
    }   

    uint32_t size=0;
    uint32_t time;
    uint32_t last_send_time;    
    
    last_send_time = GetTickCounter();
    while(1){
        size = fifo_length(&amp;amp;m_rx_fifo);                  
        if (size) {                      
            time = GetTickCounter();
            if(time &amp;lt; last_send_time){
                time = time + 0x1000000;
            }           
            if(((time - last_send_time) &amp;gt;= (int)((2 * RTC_FREQ_F)/1000)) || (size&amp;gt;=BTH_MAX_PACKET_SIZE))  {    
                app_fifo_read(&amp;amp;m_rx_fifo, buf, &amp;amp;size);
                BLE_Send(buf, size);
                last_send_time = time;        
            }
        }
    }    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int BLE_Send(unsigned char* Data, unsigned short len){
  
  int err_code;
  int sended = 0;
  unsigned short SendLen;
  unsigned SendRetryCount = 0;

  uint32_t time;
  uint32_t last_send_time;

  do{
    if (len &amp;gt; BLE_MAX_LEN){
      SendLen = BLE_MAX_LEN;
    }
    else{
      SendLen = len;
    }
    last_send_time = GetTickCounter();
    SendRetryCount = 0;
    DataSended = 0;
    do
    {
      err_code = my_ble_nus_data_send((uint8_t*)&amp;amp;Data[sended], &amp;amp;SendLen, m_conn_handle);


      time = GetTickCounter();
      if(time &amp;lt; last_send_time){
        time = time + 0x1000000;
      }                                
      
      if ((time - last_send_time) &amp;gt;= (int)((BTH_SEND_TIMEOUT * RTC_FREQ_F)/1000)){
        return sended;
      }
      
    } while ( (err_code == NRF_ERROR_BUSY) | (err_code == NRF_ERROR_RESOURCES) );

    len -= SendLen;
    sended += SendLen;
  }while(len);
  
  return sended;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sometimes RTS pin goes hi(deactive) and never come back.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 Uart to Ble Bridge</title><link>https://devzone.nordicsemi.com/thread/255302?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2020 14:11:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0eda5e4-0a25-47e8-96b5-6f715a156b01</guid><dc:creator>Turbo J</dc:creator><description>[quote userid="90537" url="~/f/nordic-q-a/62655/nrf52-uart-to-ble-bridge"]&lt;strong&gt;RTS&lt;/strong&gt; pin sticks hight level(&lt;strong&gt;deactivate&lt;/strong&gt;) fast enough and stays &lt;strong&gt;forever&lt;/strong&gt;, although receiver FIFO is empt[/quote]
&lt;p&gt;RTS is hardware controlled and will only assert when the uart(e) hardware fifo has &amp;gt;= 4 bytes in it. In other words: Your observation is not 100% correct.&lt;/p&gt;
&lt;p&gt;Further analysing requires us to be able to look into your source code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>