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

GPIOTE example not woking with NRF_LOG

Hi! I was testing  GPIOTE with pin_change_int example and tried to add a log to the push of the button.Somehow the code is not working, it is indeed changing the state of the LED but not printing my message. I'm wondering if I'm doing something wrong with the initialization of the logging function.I'm using SDK 17.0.2 with keil MDK and pca10040.

Since it's a small code I'll post it here.

#include <stdbool.h>
#include "nrf.h"
#include "nrf_drv_gpiote.h"
#include "app_error.h"
#include "boards.h"

#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

#define PIN_IN BSP_BUTTON_0
#define PIN_OUT BSP_LED_3



void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    nrf_drv_gpiote_out_toggle(PIN_OUT);
	  NRF_LOG_INFO("teste");
}
/**
 * @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output,
 * 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_TOGGLE(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);
}

void log_init(void){
	
		ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
	
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
//	
		ret_code_t error_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(error_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
	
    gpio_init();
    
    while (true)
    {
       // Do nothing.
    }
		
}


/** @} */

I tried looking on other examples that uses the logging capabilities but they have a "NRF_LOG_BACKEND_UART_ENABLED" in their sdk_config file that mine don't. I've added  this section but without sucess.

Is there any suggestions or tips on how to implement logging capabilities in this pin_change_int  example?

Thank you.

Related