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

UART LOG BACKEND constantly sends datas

Hi everyone,

I have configured the LOG module to use it with the UART in view of debugging.

I don't send anything in my loop but the UART send constantly these data :

<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 length: 38.
<info> uart: TX req id:2 leng.........

here's my main :

int main(void)
{
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("\r\nUART debugging is working");

    /*Macro for processing all log entries from the buffer.
    It blocks until all buffered entries are processed by the backend.*/
    NRF_LOG_FLUSH();
        
    timer_init();
    gpio_init();

    while (true)
    {
        // Do nothing.
    }
}

Sincerely,

Sylvain.

Parents
  • Hi,

     

    Looks like NRF_LOG is configured to output "INFO" level on nrf_drv_uart.c, as this info-print is present in nrf_drv_uart.c::nrf_drv_uart_tx_for_uarte().

    If this line is outputted continuously, it indicates that an assertion (default behavior is a soft-reset, add preprocessor define "DEBUG" to your project to enable blocking assertions) is occurring somewhere in your application.

    Could you try setting the optimization level to 0 and add a breakpoint in "app_error.c::app_error_handler()" to see if this hits?

     

    Best regards,

    Håkon

  • 1) I've added DEBUG to the preprocessor but nothing change.

    2) I put a breakpoint to "app_error.c::app_error_handler()" but it is never reach

    3) I'm not sure to understand what's the optimization level 0 ?

  • Depending on what compiler/IDE you use, the optimization level is set differently. If you are using gcc+makefiles, it is set by changing from "-O3" to "-O0". In keil, you have to enter project settings -> C/C++ and there's a drop-down menu you can set the level to '0'.

    Could you post more of your code so I can have a look at what your other functions are doing?

     

    Best regards,

    Håkon

  • I'm using Segger Embedded Studio and the optimization level is set on "none"...

    here's my main code :

    #include <stdbool.h>
    #include "nrf.h"
    #include "nrf_drv_gpiote.h"
    #include "app_error.h"
    #include "boards.h"
    #include "nrf_drv_timer.h"
    
    #include "nrf_delay.h"
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    #include "app_util_platform.h"
    
    
    #define PIN_IN 33 //BUTTON_1 
    
    #define PIN_OUT BSP_LED_0
    
    const nrf_drv_timer_t TIMER = NRF_DRV_TIMER_INSTANCE(1);
    uint8_t state = 0;
    uint16_t captured_value = 0;
    
    void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        state^=1;
    
        if (state==1){
          nrf_drv_timer_enable(&TIMER);
        }
        else{
          captured_value = nrf_drv_timer_capture (&TIMER,0);
          nrf_drv_timer_disable(&TIMER);
          nrf_drv_timer_clear(&TIMER);
        }
    }
    
    void timer_event_handler(nrf_timer_event_t event_type, void* p_context)
    {
    }
    
    /**
     * @brief Function for configuring: input PIN, output PIN,
     * and configures GPIOTE to give an interrupt on pin change.
     */
    static void gpio_init(void)
    {
        ret_code_t err_code;
    
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
    
        err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
        in_config.pull = NRF_GPIO_PIN_PULLUP;
    
        err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_in_event_enable(PIN_IN, true);
    }
    
    static void timer_init (void){
        
        ret_code_t err_code;
    
        nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
        err_code = nrf_drv_timer_init (&TIMER, &timer_cfg, timer_event_handler);
        APP_ERROR_CHECK(err_code);
    }
    
    
    int main(void)
    {
        float frequency = 0.0;
    
        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        NRF_LOG_INFO("\r\nUART debugging is working");
    
        /*Macro for processing all log entries from the buffer.
        It blocks until all buffered entries are processed by the backend.*/
        NRF_LOG_FLUSH();
            
        timer_init();
        gpio_init();
    
        while (true)
        {
          nrf_delay_ms (500);
          frequency = 16000000/captured_value;
         // NRF_LOG_INFO("Frequency: " NRF_LOG_FLOAT_MARKER " Hertz.", NRF_LOG_FLOAT(frequency));
         // NRF_LOG_FLUSH();
        }
    }

    Thanks for the support,

    Sylvain.

  • I copied your code into the examples/peripheral/gpiote example, and ran it on my pca10056, and I did not see anything bad in terms of reset or assertions.

    Does it behave like this both when debugging and when just running the example normally?

     

    Best regards,

    Håkon

  • Do you see ("\r\nUART debugging is working") on your hyperterminal ?

    Because in this example the uart logging isn't configured ...

    My project is based on the Pin_Change example.

    Yes I have the same mistake on normal Run and on debug

    King regards,

    Sylvain.

  • I copied my main program and the sdk_config into the "gpiote" example and I added the libraries for nrf logging and uart drv.

    And the result is the same behavior.

    Here's the project :

    pin_change_int - copie.zip

    Note that I use Segger as compiler ...

    Sincerely,

    Sylvain.

Reply Children
No Data
Related