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

  • Hi

    Can you provide the return of the UART callback function and debug log so we can get some more details as to what's going on here?

    A common mistake in custom boards is that the 32.768kHz crystal is soldered on the wrong way (90 degrees off), so a malfunctioning 32kHz crystal may indeed be your problem.

    Please try changing the following defines in your sdk_config.h file to enable the internal RC oscillator and the correct calibration interval.

    // <h> Clock - SoftDevice clock configuration
    
    //==========================================================
    // <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
     
    // <0=> NRF_CLOCK_LF_SRC_RC 
    // <1=> NRF_CLOCK_LF_SRC_XTAL 
    // <2=> NRF_CLOCK_LF_SRC_SYNTH 
    
    #ifndef NRF_SDH_CLOCK_LF_SRC
    #define NRF_SDH_CLOCK_LF_SRC 0
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
    #ifndef NRF_SDH_CLOCK_LF_RC_CTIV
    #define NRF_SDH_CLOCK_LF_RC_CTIV 16
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
    // <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
    // <i>  if the temperature has not changed.
    
    #ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
    #define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
    #endif
    
    // <o> NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
     
    // <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
    // <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
    // <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
    // <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
    // <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
    // <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
    // <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
    // <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
    // <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
    // <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
    // <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
    // <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 
    
    #ifndef NRF_SDH_CLOCK_LF_ACCURACY
    #define NRF_SDH_CLOCK_LF_ACCURACY 1
    #endif

    Best regards,

    Simon

  • Simonr,

    Thanks for the suggestions, 

    1. I have configured above macro with sdk config and still not seeing any output with uart.
    2. I have enabled log and RTT log but it is not showing any log with swd debugger. Please review my attached sdk_config.h
    now  I have taken ble blinky example and trying to test nRF log option first. 
    I can understand i am doing wrong, please correct me. 

    3. If internal RC enabled how to veri3108.sdk_config.hfy it is running with internal RC ?

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

  • Hi again

    Sorry about the late reply, but we're currently catching up with the backlog from the Easter vacation here in Norway.

    Can you upload your project from one step up in the hierarchy (...\SDK_FOLDER\examples\peripheral\uart)so the main file is added as well? This way I should be able to reproduce it on a DK on my side to see if the problem persists there.

    Are you able to run the unmodified \peripheral\uart example on your module at all (in normal mode)? Are you able to use the RTT viewer to see log messages when your application is running in normal mode, so that we can get any information of where the application runs into problems?

    In our experience, live debugging sessions over screen sharing/meetings are generally not very effective, so I would suggest sticking to the forum.

    Best regards,

    Simon

Related