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

UART example goes to debug window

I have been developing some nrf52832 code (SDK 17.0.2) using the Segger RTT debug window for logging.  I added the code from the UART example but the printf goes to the debug window not the UART.

In my sdk_config file I have the following:

// NRF_LOG_BACKEND_SERIAL_USES_UART - If enabled data is printed over UART
//==========================================================
#ifndef NRF_LOG_BACKEND_SERIAL_USES_UART
#define NRF_LOG_BACKEND_SERIAL_USES_UART 1
#endif

// NRF_LOG_BACKEND_SERIAL_USES_RTT - If enabled data is printed using RTT
//==========================================================
#ifndef NRF_LOG_BACKEND_SERIAL_USES_RTT
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 0
#endif

//==========================================================
// <e> NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend
//==========================================================
#ifndef NRF_LOG_BACKEND_RTT_ENABLED
#define NRF_LOG_BACKEND_RTT_ENABLED 0
#endif

// <e> NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend
//==========================================================
#ifndef NRF_LOG_BACKEND_UART_ENABLED
#define NRF_LOG_BACKEND_UART_ENABLED 1
#endif

// <o> NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin
#ifndef NRF_LOG_BACKEND_UART_TX_PIN
#define NRF_LOG_BACKEND_UART_TX_PIN 6
#endif

What else needs to be done to get the UART example to output on the UART and not on RTT?

Thanks for your help,

Tim

Parents Reply
  • Hi,

     My guess is that it goes into the error handler in app_uart.c or app_uart_fifo.c. 

    app_uart_event.data.error_communication is set in the error handler and will contain the value in the ERRORSRC register for the UART peripheral. Use the debugger and check what value this is set to.

    Also, regarding the logging module, are you using deferred or in-place logging when you log over RTT? 

    regards

    Jared 

Children
  • I found the issue.  When I configure the I2S port with nrf_drv_i2s_init() the ERRORSRC for the UART gets set to 0xC.  Why would the I2S effect the UART?  Do they share resources?  How can I make them play nicely together? 

    Thanks,

    Tim

  • Hi Tim,

    They do not use the same resources as shown by the instantiation table. Could it be a pin conflict, are they assigned to use the same pins?

    regards

    Jared 

  • Jared, it is indeed a pin issue but it seems like a bug.  The error happens in nrf_i2s_pins_set when I the library function tries to set the SDOUT pin to 0x255, which should mean unused.  When this value is written to the PSEL.SDOUT register the UART error is thrown.  To me it looks like a bug?  What might I be doing wrong?

    __STATIC_INLINE void nrf_i2s_pins_set(NRF_I2S_Type * p_reg,
    uint32_t sck_pin,
    uint32_t lrck_pin,
    uint32_t mck_pin,
    uint32_t sdout_pin,
    uint32_t sdin_pin)
    {
    p_reg->PSEL.SCK = sck_pin;
    p_reg->PSEL.LRCK = lrck_pin;
    p_reg->PSEL.MCK = mck_pin;
    p_reg->PSEL.SDOUT = sdout_pin;
    p_reg->PSEL.SDIN = sdin_pin;
    }

    Here is my code that preceeds the above library function, as you can see I am setting the pin to unconnected, and indeed in the nrf_i2s_pins_set function it seeks to set the pin value to 0x255.  I am befuddled.

    uint32_t config_I2S()
    {
    nrf_drv_i2s_config_t config = NRF_DRV_I2S_DEFAULT_CONFIG;
    // In Master mode the MCK frequency and the MCK/LRCK ratio should be
    // set properly in order to achieve desired audio sample rate (which
    // is equivalent to the LRCK frequency).
    config.sdin_pin = DIN_PIN;
    config.sdout_pin = NRF_I2S_PIN_NOT_CONNECTED; // This pin is not used
    config.mck_setup = NRF_I2S_MCK_32MDIV3; //MCLK 10.666667MHz
    config.ratio = NRF_I2S_RATIO_256X; //LR clock (WCLK) 41.6667KHz
    config.channels = NRF_I2S_CHANNELS_LEFT; // Use only the right channel (comes in on the left?)
    config.mode = NRF_I2S_MODE_MASTER;
    config.sample_width = NRF_I2S_SWIDTH_16BIT;
    config.format = NRF_I2S_FORMAT_I2S;
    //config.format = NRF_I2S_FORMAT_ALIGNED;
    config.lrck_pin = WCLK_PIN;
    config.mck_pin = MCLK_PIN;
    config.sck_pin = BCLK_PIN;

    uint32_t err_code = NRF_SUCCESS;
    err_code = nrf_drv_i2s_init(&config, data_handler);

    return(err_code);

    }

  • Hi,

    This seems strange. Have you reproduced this on a development kit? What happens if you assign the SDOUT pin to a physical pin, still getting an error from the UART driver? 

    regards

    Jared 

  • Hi Jared,

    Sure enough everything works fine when I assign SDOUT to an unused physical pin (pin 9).  But when I assign it to the unused (0xFF) it sets the UART error flag as described.  I really don't want SDOUT coming out so it would be nice if there was a fix for this.

Related