Call to app_uart_put() not putting anything on the TX Line

Hello,

I've been trying to get my call to app_uart_put() to actually place bytes on the TX pin. Interestingly enough, my call to app_uart_get() works fine and is able to receive all the commands on the RX pin. I am using SDK v17.0.2. 

My code that initializes the UART is fairly boilerplate:

   if (!uart_instance_activated)
    {
        uart_instance_activated = true;
        uint32_t err_code = NRF_SUCCESS;
        const app_uart_comm_params_t comm_params =
        {
            UART_RX_PIN,
            UART_TX_PIN,
            UART_RTS_PIN_NUMBER,
            UART_CTS_PIN_NUMBER,
            UART_HWFC,
            false,
            NRF_UART_BAUDRATE_115200
        };

        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); 
    }

My code that calls app_uart_put()

uint8_t transportSend( const uint16_t bufferSize, uint8_t *pBuffer )
{
    if ( pBuffer == NULL )
    {
        NRF_LOG_INFO("NULL?");
        return TRANSPORT_ERROR;
    }

    uint32_t status = NRF_SUCCESS;

    while (app_uart_put(START_BYTE) != NRF_SUCCESS);
    nrf_delay_ms(10);

    for ( uint16_t i = 0; i < bufferSize; i++ )
    {
        //NRF_LOG_INFO("pBuffer[%d] = %d", i, pBuffer[i]);
        // UART is spaming 0xFF so it has to be escaped
        if ( ( pBuffer[i] == START_BYTE ) ||
             ( pBuffer[i] == STOP_BYTE ) ||
             ( pBuffer[i] == ESCAPE_BYTE ) ||
             ( pBuffer[i] == 0xFF ) )
        {
            //status = app_uart_put( ESCAPE_BYTE );
            while (app_uart_put(ESCAPE_BYTE) != NRF_SUCCESS);
            nrf_delay_ms(10);

            while (app_uart_put(escapeByte( pBuffer[i] )) != NRF_SUCCESS);
            nrf_delay_ms(10);
        }
        else
        {
            while (app_uart_put(pBuffer[i]) != NRF_SUCCESS);
            nrf_delay_ms(10);
        }
    } // end of for-loop

    while (app_uart_put(STOP_BYTE) != NRF_SUCCESS);
    nrf_delay_ms(10);
  
    return TRANSPORT_SUCCESS;
}

and Like I said, my code that calls app_uart_get() works just fine:

static int cala_getChar()
{
    uint8_t input = 0;
    app_uart_get(&input);
    return input;
}

Is app_uart_put() not being called correctly? Doubled checked sdk_config.h and NRFX_UART_ENABLED is 1

Parents
  • Hi

    Have you checked out the UART example projects in the SDK to see how they initialize and utilize the app_uart_put() function? Also, what pin have you set the UART TX pin as in your application?

    Best regards,

    Simon

  • Hi Simon,

    Changing to PORT_0 pins didn't work, unfortunately. 

    Are there certain flags that need to be turned on in sdk_config.h?

    For instance, I noticed that 

    // RETARGET_ENABLED  - retarget - Retargeting stdio functions
    #ifndef RETARGET_ENABLED
    #define RETARGET_ENABLED 1
    #endif


    I added this into my code, but still not seeing anything on the TX line. Also,

    My code has

    #ifndef APP_UART_DRIVER_INSTANCE
    #define APP_UART_DRIVER_INSTANCE 1
    #endif


    Does this need to be 0?


    What about:

    #ifndef NRFX_UARTE_ENABLED
    #define NRFX_UARTE_ENABLED 1
    #endif
    //  NRFX_UARTE0_ENABLED - Enable UARTE0 instance 
    #ifndef NRFX_UARTE0_ENABLED
    #define NRFX_UARTE0_ENABLED 0
    #endif
    
    //  NRFX_UARTE1_ENABLED - Enable UARTE1 instance 
    #ifndef NRFX_UARTE1_ENABLED
    #define NRFX_UARTE1_ENABLED 0
    #endif

    ?



    Not sure why RX line works fine, but TX produces 0 output. Do I need to configure TX pull sense a certain way?




Reply
  • Hi Simon,

    Changing to PORT_0 pins didn't work, unfortunately. 

    Are there certain flags that need to be turned on in sdk_config.h?

    For instance, I noticed that 

    // RETARGET_ENABLED  - retarget - Retargeting stdio functions
    #ifndef RETARGET_ENABLED
    #define RETARGET_ENABLED 1
    #endif


    I added this into my code, but still not seeing anything on the TX line. Also,

    My code has

    #ifndef APP_UART_DRIVER_INSTANCE
    #define APP_UART_DRIVER_INSTANCE 1
    #endif


    Does this need to be 0?


    What about:

    #ifndef NRFX_UARTE_ENABLED
    #define NRFX_UARTE_ENABLED 1
    #endif
    //  NRFX_UARTE0_ENABLED - Enable UARTE0 instance 
    #ifndef NRFX_UARTE0_ENABLED
    #define NRFX_UARTE0_ENABLED 0
    #endif
    
    //  NRFX_UARTE1_ENABLED - Enable UARTE1 instance 
    #ifndef NRFX_UARTE1_ENABLED
    #define NRFX_UARTE1_ENABLED 0
    #endif

    ?



    Not sure why RX line works fine, but TX produces 0 output. Do I need to configure TX pull sense a certain way?




Children
Related