PlatformIO Community

The effects of Zephyr LOGGING on system behavior

Hello, guys.

I have nRF51822 SoC running Zephyr OS. Among the other things, the nRF should communicate (over I2C) with the touch controller that will fire an interrupt every 20ms if the finger is pressing the touch area. This part of the system is illustrated below:

image

The part of the prj.conf file related to the logging is as follows:

CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_LOG_BUFFER_SIZE=2048
CONFIG_LOG_DEFAULT_LEVEL=4

nRF GPIO line connected to the INT pin is configured like this:

nrfx_gpiote_in_config_t config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
config.pull = p_btn->pull_cfg;
err_code = nrfx_gpiote_in_init(p_btn->pin_no, &config, gpiote_event_handler);

What I am noticing is that my design works as expected only under the following conditions:

  1. I have CONFIG_LOG_MODE_IMMEDIATE=y line in prj.conf file AND
  2. I am sending some debug print from within gpiote_event_handler() interrupt routine (for example, at least LOG_INF("."); )

If I disable immediate logs OR remove debug print line from the GPIO interrupt routine, the design does not work as expected.

Can somebody explain to me what is going on here, how the way the system is debugged influences the behavior of the system and what should I do to avoid this? I am now becoming a little bit paranoid.

Thanks in advance for your time and efforts.

Cheers :beers:

Bojan