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

Missing APP_UART_TX_EMPTY event

Hi!

I am working with an application were two nRF52832 shall communicate over UART in half-duplex 1-wire mode (similar to what is described here but I use different pins for Tx/Rx: devzone.nordicsemi.com/.../). The FIFO version of app_uart (app_uart_fifo.c) and SDK 13.0.0 is used.

APP_UART_TX_EMTY is used to check that data been sent before Tx pin is switched to input mode. The problem I am facing is that I don't get the event if I just use app_uart_put() to transmit single data bytes from unit 1 to unit 2. But if I add printf("\r\n") the event occur as expected. I have verified with oscilloscope that first data byte is sent. Code snippets are shown below.

    void uart_event_handler(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);
        }
        else if (p_event->evt_type == APP_UART_TX_EMPTY)
        {
            tx_empty_flag = true;
        }
        else if (p_event->evt_type == APP_UART_DATA_READY)
        {
            data_ready_flag = true;
        }
    }
    
    
    
    while (true)
    {
       while (app_uart_put('A') != NRF_SUCCESS);
       printf("\r\n");  // no APP_UART_TX_EMPTY is received in uart_event_handler if line deleted 
    
       while (tx_empty_flag != true );
       tx_empty_flag = false;
       disable_tx();  
    
    }

Could anyone explain this?

Thanks in advance, Mattias

Parents
  • Hi,

    By APP_UART_TX_EVENT as you have written in your post I assume you mean APP_UART_TX_EMPTY?

    I did a quick test using the peripheral UART example from SDK 13 and your code snippets. My application reached the APP_UART_TX_EMPTY event in the handler regardless of whether the printf() line was commented out or not.

    1. Can you also show how you configure the UART?
    2. And do you have other things going on in your code? Any other peripherals using interrupts for example?
    3. Are tx_empty_flag and data_ready_flag declared as volatile booleans?
Reply
  • Hi,

    By APP_UART_TX_EVENT as you have written in your post I assume you mean APP_UART_TX_EMPTY?

    I did a quick test using the peripheral UART example from SDK 13 and your code snippets. My application reached the APP_UART_TX_EMPTY event in the handler regardless of whether the printf() line was commented out or not.

    1. Can you also show how you configure the UART?
    2. And do you have other things going on in your code? Any other peripherals using interrupts for example?
    3. Are tx_empty_flag and data_ready_flag declared as volatile booleans?
Children
No Data
Related