<?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>How to send data using gpio (rx, tx pin)?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68174/how-to-send-data-using-gpio-rx-tx-pin</link><description>Hi, all 
 I&amp;#39;m using nrf52832 pca10040, s132.. 
 
 I want to send and receive data over Tx , Rx pin.. with my custom board, cm1106 model.. 
 &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; I&amp;#39;ve connected the two devices directly. 
 
 So, what I want to do is.. 
 i want to send data, 0x11 0x01</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 11 Nov 2020 19:26:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68174/how-to-send-data-using-gpio-rx-tx-pin" /><item><title>RE: How to send data using gpio (rx, tx pin)?</title><link>https://devzone.nordicsemi.com/thread/279586?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 19:26:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3303512-6e05-49d3-b17d-1c6828643d82</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="lyrics"]Will TX_EMPTY be called when all the values of 0x11 are sent?[/quote]
&lt;p&gt;The event will be generated whenever the FIFO is empty. When this is depends on how fast the application puts bytes into the FIFO, and how fast the UART peripheral is able to transmit the bytes.&lt;/p&gt;
[quote user="lyrics"]And since app_uart_get is defined in TX_EMPTY, err_code is not SUCCESS, where should I define it?[/quote]
&lt;p&gt;You should call&amp;nbsp;app_uart_get() in the&amp;nbsp;&lt;span&gt;APP_UART_DATA_READY event case, if you want to read the data as soon as it is received by the UART peripheral.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data using gpio (rx, tx pin)?</title><link>https://devzone.nordicsemi.com/thread/279407?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 08:08:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16301147-5900-47f6-8007-b783cfc4e154</guid><dc:creator>lyrics</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I got the event &amp;quot;APP_UART_TX_EMPTY&amp;quot; and looked at the flow with breakpoint,,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Will TX_EMPTY be called when all the values of 0x11 are sent?&lt;/span&gt;&lt;br /&gt;&lt;span&gt;And since app_uart_get is defined in TX_EMPTY, err_code is not SUCCESS, where should I define it?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data using gpio (rx, tx pin)?</title><link>https://devzone.nordicsemi.com/thread/279396?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 07:21:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c77c69f6-65a1-46a1-860c-02bfa517d044</guid><dc:creator>jawadk</dc:creator><description>&lt;p&gt;Hi Lyics,&lt;/p&gt;
&lt;p&gt;you will got the &amp;quot;&lt;span&gt;APP_UART_DATA_READY&lt;/span&gt;&amp;quot; event when you receive data over UART and not when you finish sending data, instead you will got the event &amp;quot;APP_UART_TX_EMPTY&amp;quot;, this event indicating that UART has completed transmission of all available data in the TX FIFO, so use it as Nordix example uses the&amp;nbsp;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;APP_UART_DATA_READY&lt;/span&gt;&lt;span&gt;&amp;quot; event&amp;nbsp;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Plus pay&amp;nbsp;&lt;/span&gt;attention to what is the returned value you got from the function &amp;quot;&lt;span&gt;app_uart_put&amp;quot; to see if you have any problem regarding the uard driver.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;JK&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data using gpio (rx, tx pin)?</title><link>https://devzone.nordicsemi.com/thread/279375?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 00:45:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e0f6b7f-e632-4c64-b362-0a0d1841e2e2</guid><dc:creator>lyrics</dc:creator><description>&lt;p&gt;Hi, jawadk&lt;/p&gt;
&lt;p&gt;Thank you for your reply..&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I sent the data through &amp;#39;app_uart_put&amp;#39;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If the data was sent well, shouldn&amp;#39;t &amp;#39;APP_UART_DATA_READY&amp;#39; be called on the code?..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Why isn&amp;#39;t the event happening?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    bool erase_bonds;

    // Initialize.
    uart_init();

    send_data();

    // Enter main loop.
    while(true)
    {
          //receive_data();
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static 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   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
        .baud_rate    = NRF_UART_BAUDRATE_9600
    };
//    nrf_gpio_cfg_input(RX_PIN_NUMBER, NRF_GPIO_PIN_NOPULL);
//    nrf_gpio_cfg_output(TX_PIN_NUMBER);

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_evt_callback,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void send_data()
{
    uint32_t    err_code;
    uint8_t     send_data[UART_TX_BUF_SIZE];
    uint32_t    length = 4;

    send_data[0] = 0x11;
    send_data[1] = 0x01;
    send_data[2] = 0x01;
    send_data[3] = 0xed;

    for(uint32_t i = 0; i &amp;lt; length; i++)
    {
        {
            err_code = app_uart_put(send_data[i]);
            if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY))
            {
                NRF_LOG_ERROR(&amp;quot;Failed Error 0x%x. &amp;quot;, err_code);
                APP_ERROR_CHECK(err_code);
            }
        } while (err_code == NRF_ERROR_BUSY);
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_evt_callback(app_uart_evt_t * uart_evt) 
{
    uint8_t   byte;
    uint32_t  err_code;
    switch (uart_evt-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            printf(&amp;quot;b\r\n&amp;quot;); 
            err_code = app_uart_get(&amp;amp;byte);
            if(err_code == NRF_SUCCESS)
            {
                printf(&amp;quot;success..\r\n&amp;quot;);
            }
        break;
        
        ...
        
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data using gpio (rx, tx pin)?</title><link>https://devzone.nordicsemi.com/thread/279166?ContentTypeID=1</link><pubDate>Tue, 10 Nov 2020 09:42:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:779d5236-42a7-43e3-a989-f52034cf46c5</guid><dc:creator>jawadk</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="93536" url="~/f/nordic-q-a/68174/how-to-send-data-using-gpio-rx-tx-pin"]1.&amp;nbsp;Is it correct to use &amp;#39;app_uart_put&amp;#39; to send data?..[/quote]
&lt;p&gt;Yes this is the function to send data over uart, this function sends one byte at a time so you need to make a for loop for sending all the bytes you mentioned above.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="93536" url="~/f/nordic-q-a/68174/how-to-send-data-using-gpio-rx-tx-pin"]&lt;p&gt;&lt;span&gt;2. Even if i do not receive the response data,,&amp;nbsp; h&lt;/span&gt;&lt;span&gt;ow can I check that those 0x11 ... data send well? (using nRF connect?)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;You can use a UART to USB converter, plug it to your PC an use a terminal&amp;nbsp;to open the right Comport to see the sent bytes from the board over UART.&lt;/p&gt;
[quote userid="93536" url="~/f/nordic-q-a/68174/how-to-send-data-using-gpio-rx-tx-pin"]&lt;p&gt;&lt;span&gt;3. Am I have to initialize custom device&amp;#39;s gpio, too?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;You don&amp;#39;t need to use custom gpios if you use the code and pins for&amp;nbsp;&lt;span&gt;pca10040&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hope this was helpful.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;JK&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>