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 Children
  • 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.

  • Hi,

    I tried to reproduce this by merging the UART and I2S example from the SDK and using loopback on both peripherals. I assigned SDOUT to 0xFF and the UART did not go into the error handler. Would you mind sharing a minimal project, that reproduces the issue on the development kit.

    Thank you.

    Also, I'm going to be out office due to the holidays so expect a bit late reply.

    regards

    Jared 

Related