<?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 can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90777/how-can-i-implement-uart-rx-ppi-with-gpio</link><description>Hi, I use nRF52840, with SDK 15.3.0 
 I would like to toggle LED every time receive 1 byte to UART. 
 So I wrote down the code. 
 
 
 Thanks in advance!</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Aug 2022 10:57:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90777/how-can-i-implement-uart-rx-ppi-with-gpio" /><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/381984?ContentTypeID=1</link><pubDate>Wed, 17 Aug 2022 10:57:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0231ed92-216d-4889-bebf-39407c5b058f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I see the problem now. To enable reception you have to provide the driver with a application buffer to hold store the received bytes. You also have to repeat this after receiving the&amp;nbsp;NRFX_UART_EVT_RX_DONE event.&lt;/p&gt;
&lt;p&gt;Like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t m_rx_buffer[1];

void UART_dataHandler(void)
{
    ...
    nrfx_uart_rx(&amp;amp;uart1_inst, m_rx_buffer, sizeof(m_rx_buffer));
}

int main(void)
{
    uart1_init();
    
    ppi_init();
    nrfx_uart_rx(&amp;amp;uart1_inst, m_rx_buffer, sizeof(m_rx_buffer));
    
    while(1)
    {}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You may also refer to the app_uart library implementation used by ble_app_uart to see how the driver APIs are used there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/381249?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2022 00:03:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9de25a8b-cdda-4be2-87b5-8fdedaa18f4a</guid><dc:creator>William_dev</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Here the related UART code initial part, IRQ handler, main&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void UART_dataHandler(void)
{
    static uint8_t databuff;
    printf(&amp;quot;%x\r\n&amp;quot;, databuff);
}

void UART_idleHandler(void)
{
}
/*    UART ISR    */
void UART_IRQ_handler(const nrfx_uart_event_t * p_event, void * p_context)
{
    switch(p_event -&amp;gt; type)
    {
        case NRFX_UART_EVT_RX_DONE:
            UART_dataHandler();
            break;
        case NRFX_UART_EVT_TX_DONE:
            break;
        case NRFX_UART_EVT_ERROR:
            NRF_LOG_INFO(&amp;quot;INVALID_IRQ\r\n&amp;quot;);
            UART_idleHandler();
            break;
    }
}

void uart1_init(void)
{
    uint32_t err_code;

    nrfx_uart_config_t uart1_config = {TX_PIN,
                                       RX_PIN,
                                       CTS_PIN,
                                       RTS_PIN,
                                       NULL,
                                       NRF_UART_HWFC_DISABLED,
                                       NRF_UART_PARITY_EXCLUDED,
                                       UART_BR_115200,
                                       6};

    nrfx_uart_init(&amp;amp;uart1_inst, &amp;amp;uart1_config, UART_IRQ_handler);
    nrf_uart_int_enable(NRF_UART0, NRF_UART_INT_MASK_ERROR | NRF_UART_INT_MASK_RXDRDY);
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_ERROR | NRF_UART_EVENT_RXDRDY);
    //nrf_uart_task_trigger(NRF_UART0, NRF_UART_TASK_STARTRX);
}

static void ppi_init()
{
        uint32_t err_code;

        uint32_t uart_event_addr;
        uint32_t gpio_task_addr;
        
        nrf_ppi_channel_t ppi_channel_uart_gpio_toggle;

        err_code = nrf_drv_ppi_init();
        if((err_code != 0) &amp;amp;&amp;amp; (err_code != NRF_ERROR_MODULE_ALREADY_INITIALIZED))
        {
            APP_ERROR_CHECK(err_code);
        }

        nrf_drv_gpiote_out_config_t config = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);

        err_code = nrfx_gpiote_out_init(LED_1, &amp;amp;config);
        APP_ERROR_CHECK(err_code);

        err_code = nrfx_ppi_channel_alloc(&amp;amp;ppi_channel_uart_gpio_toggle);
        APP_ERROR_CHECK(err_code);

        uart_event_addr = nrfx_uart_event_address_get(&amp;amp;uart1_inst, NRF_UART_EVENT_RXDRDY);
        gpio_task_addr = nrfx_gpiote_out_task_addr_get(LED_1);
        
        err_code = nrfx_ppi_channel_assign(ppi_channel_uart_gpio_toggle, uart_event_addr, gpio_task_addr);
        APP_ERROR_CHECK(err_code);

        err_code = nrfx_ppi_channel_enable(ppi_channel_uart_gpio_toggle);
        APP_ERROR_CHECK(err_code);

        nrfx_gpiote_out_task_enable(LED_1);
}

int main(void)
{
    uart1_init();
    
    ppi_init();
    nrfx_uart_rx_enable(&amp;amp;uart1_inst);
    
    while(1)
    {}
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/381242?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2022 19:04:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:089c475c-13ad-441e-be8f-a0af101f665d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Would you mind sharing the rest of the UART related code? I am not sure I understand exactly how you have configured it now, or why you only get the first RX byte event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/381129?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2022 08:29:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89eb072c-4688-44e9-93ab-e79d643fe440</guid><dc:creator>William_dev</dc:creator><description>&lt;p&gt;Hi, I appreciate to your reply.&lt;/p&gt;
&lt;p&gt;Let me go back to second question.&lt;/p&gt;
&lt;p&gt;I tried UARTE but It cause matter to system that I designed.&lt;/p&gt;
&lt;p&gt;As, is there any answer use UART peripheral?&lt;/p&gt;
&lt;p&gt;The matter is when I receive one byte, just LED toggle once. And receive next one byte, there&amp;#39;s no response to LED.&lt;/p&gt;
&lt;p&gt;Plz check the code below.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void ppi_init()
{
            uint32_t err_code;

            uint32_t uart_event_addr;
            uint32_t gpio_task_addr;
            
            nrf_ppi_channel_t ppi_channel_uart_gpio_toggle;
    
            err_code = nrf_drv_ppi_init();
            if((err_code != 0) &amp;amp;&amp;amp; (err_code != NRF_ERROR_MODULE_ALREADY_INITIALIZED))
            {
                APP_ERROR_CHECK(err_code);
            }
    
            nrf_drv_gpiote_out_config_t config = GPIOTE_CONFIG_OUT_TASK_TOGGLE(0);
    
            err_code = nrf_drv_gpiote_out_init(LED_1, &amp;amp;config);
            APP_ERROR_CHECK(err_code);
    
            err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel_uart_gpio_toggle);
            APP_ERROR_CHECK(err_code);
    
            uart_event_addr = nrfx_uart_event_address_get(&amp;amp;uart1_inst, NRF_UART_EVENT_RXDRDY);
            gpio_task_addr = nrfx_gpiote_out_task_addr_get(LED_1);
            
            err_code = nrfx_ppi_channel_assign(ppi_channel_uart_gpio_toggle, uart_event_addr, gpio_task_addr);
            APP_ERROR_CHECK(err_code);
    
            err_code = nrf_drv_ppi_channel_enable(ppi_channel_uart_gpio_toggle);
            APP_ERROR_CHECK(err_code);
    
            nrfx_gpiote_out_task_enable(LED_1);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;William.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/381095?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2022 06:44:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79cc1b33-14de-4493-9a08-eeb1345a7c1a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;DMA is mandatory with UARTE, but that does not mean you will not get an interrupt. You can set the DMA receive buffer to &amp;#39;1&amp;#39; byte if you want the uarte driver callback to be called for every received byte.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/381072?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2022 01:29:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:595e06f9-dc6c-42b1-8ad0-3aac8729fe9f</guid><dc:creator>William_dev</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I studied UART, UARTE&amp;#39;s difference. UARTE is added EasyDMA to UART.&lt;/p&gt;
&lt;p&gt;However, I use UART peripheral IRQ, with Timer PPI. Can I use UARTE peripheral IRQ not DMA?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/380726?ContentTypeID=1</link><pubDate>Tue, 09 Aug 2022 06:23:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7109d41-9b24-4802-b5c0-f25388375d64</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Please try to use the UART&lt;strong&gt;E&amp;nbsp;&lt;/strong&gt;peripheral instead (i.e. &lt;span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uarte.html?cp=4_2_0_34#concept_ayq_ycm_wr"&gt;UARTE — Universal asynchronous receiver/transmitter with EasyDMA&lt;/a&gt;&lt;/span&gt;) and not &lt;span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uart.html?cp=4_2_0_49#concept_dm5_drw_sr"&gt;UART — Universal asynchronous receiver/transmitter&lt;/a&gt;). The legacy UART will only trigger the RXDRDY event after the byte has been moved to the RXD register as noted here in the PS:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span&gt;The UART receiver chain implements a FIFO capable of storing six incoming RXD bytes before data is overwritten. Bytes are extracted from this FIFO by reading the RXD register. When a byte is extracted from the FIFO a new byte pending in the FIFO will be moved to the RXD register. The UART will generate an RXDRDY event every time a new byte is moved to the RXD register. (&lt;a title="Reception" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uart.html?cp=4_2_0_49_4#concept_isd_nsw_sr"&gt;Reception&lt;/a&gt;)&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/380721?ContentTypeID=1</link><pubDate>Tue, 09 Aug 2022 05:12:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b90f1e67-8746-43d3-a489-519f41fdfd35</guid><dc:creator>William_dev</dc:creator><description>&lt;p&gt;This time, just once toggle as UART event done.&lt;/p&gt;
&lt;p&gt;How can I toggle LED at every UART RX event use the ppi?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/380693?ContentTypeID=1</link><pubDate>Tue, 09 Aug 2022 01:02:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fecd217-f8c7-4a6d-afd0-b4b3600b1f19</guid><dc:creator>William_dev</dc:creator><description>&lt;p&gt;Hello, Vidar&lt;/p&gt;
&lt;p&gt;Thank for your advice.&lt;/p&gt;
&lt;p&gt;It works changed TASK_STARTRX to EVENT_RXDRDY.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I implement UART RX PPI with GPIO?</title><link>https://devzone.nordicsemi.com/thread/380606?ContentTypeID=1</link><pubDate>Mon, 08 Aug 2022 12:15:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d1e3e17-bfda-4947-8895-f31d5a4d1b55</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You are retrieving the task address here:&lt;/p&gt;
&lt;p&gt;uart_event_addr = nrfx_uart_event_address_get(&amp;amp;uart1_inst, &lt;strong&gt;NRF_UART_TASK_STARTRX&lt;/strong&gt;);&lt;/p&gt;
&lt;p&gt;while it should have been&lt;/p&gt;
&lt;p&gt;uart_event_addr = nrfx_uart_event_address_get(&amp;amp;uart1_inst, &lt;strong&gt;NRF_UART_EVENT_RXDRDY&lt;/strong&gt;);&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>