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

UART works only debug mode

Hi,

I am using own hardware board based on https://www.raytac.com/product/ins.php?index_id=24  module, it uses nRF52840.

I

I am facing an strange issue that UART is not working in normal mode but it is transferring a char when i add break point and run it. 

If just keep in debug mode and run still it is not sending anything to uart transfer only when i add break point that too with single char put.

HI have taken uart example and removed the uart get byte part and kept only uart put byte part with default ascii char for every 500ms. 

/**
 * @brief Function for main application entry.
 */
int main(void)
{
    uint32_t err_code;

   // bsp_board_init(BSP_INIT_LEDS);

	
    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          UART_HWFC,
          false,
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_115200
#else
          NRF_UARTE_BAUDRATE_115200
#endif
      };

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

#ifndef ENABLE_LOOPBACK_TEST
    printf("\r\nUART example started.\r\n");

    while (true)
    {
        uint8_t cr;
        //while (app_uart_get(&cr) != NRF_SUCCESS);
			cr = 'A';
        while (app_uart_put(cr) != NRF_SUCCESS);
			LED0_Toggle();
        nrf_delay_ms(500);
    }
#else

    // This part of the example is just for testing the loopback .
    while (true)
    {
        uart_loopback_test();
    }
#endif
}

P0.00 and P0.01 are connected to external 32Khz crystal, I dont have way to verify the crystal generate clock or not. Even if external crystal failed to work i am expecting internal RC to work. 

Please help me to understand how to enable the RC clock and soft device if required . 

Or what could the root cause of the issue ?

I have attached uart example code with sdkconfig i am using it. Please help me with this. 

SDK used: \nRF5_SDK_17.0.2_d674dde\examples\peripheral\uart

r2n_uart_test.zip

Parents
  • Hi

    1. What kind of output do you see when using the UART in debug mode? From the sdk_config.h file you attached I see that you're using both the NRF_LOG_BACKEND_RTT and BACKEND_UART. Please try setting NRF_LOG_BACKEND_UART_ENABLED to 0 to allow your application to use the UART peripheral instead of the logging module.

    2. Setting the NRF_LOG_BACKEND_UART_ENABLED to 0 should let you see the RTT log. When both are set to 1 there will be conflicts in the logging module regarding which one should be used, and that is likely causing problems for you

    3. I see that you have not edited the NRF_SDH_CLOCK_LF_SRC, NRF_SDH_CLOCK_LF_RC_CTIV, NRF_SDH_CLOCK_LF_RC_TEMP_CTIV, or NRF_SDH_CLOCK_LF_ACCURACY in the sdk_config.h file you attached. Setting NRF_SDH_CLOCK_LF_SRC is what defines what clock source you're using, so if you set this to 0, the internal RC oscillator will be used instead of the XTAL.

    Best regards,

    Simon

  • Simonr,

    Thanks for your suggestions again.

    It didn't work , i have corrected the clock source to RC i.e 0 and disabled log to UART part.

    A simple program runs where I am sending single char to uart inside while with a delay of 500ms. When I run it with out debug mode i am not seeing any character coming out from UART. When I put break point while sending a char to UART , and run it in debug i am able to see the char everytime when press run button since it comes to break point on every click.

    Do you have any option to help me through remote screen sharing or meeting ? I have to go for productions because of this simple UART issue everything stuck. 

Reply
  • Simonr,

    Thanks for your suggestions again.

    It didn't work , i have corrected the clock source to RC i.e 0 and disabled log to UART part.

    A simple program runs where I am sending single char to uart inside while with a delay of 500ms. When I run it with out debug mode i am not seeing any character coming out from UART. When I put break point while sending a char to UART , and run it in debug i am able to see the char everytime when press run button since it comes to break point on every click.

    Do you have any option to help me through remote screen sharing or meeting ? I have to go for productions because of this simple UART issue everything stuck. 

Children
No Data
Related