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

Dynamically switching Logs

Hi, 

I am using nrf52840 Preview - DK, with SDK v15.3.0 and Softdevice API 6.1.1

As we need to set NRF_LOG by setting the NRF_LOG_ENABLE and NRF_LOG_BACKEND_URAT_ENABLE  and NRF_FPRINTF to 0 in the sdk_config file to conserver power, which is a compile time procedure.

Is there any run-time solution to turn ON and OFF logs, I need to print some important messages once in a while and then turn OFF the logs to conserve power, is there a solution ?

Thanks.  

Parents Reply Children
  • I assume that resetting the device whenever you turn the switch off is not a viable solution for you? Because then you can initialize the log based on that. If not, you will have to do this based on UART, and initialize it when you flick the switch on, uninitialize it when you switch it off, and have some function call that will print the log message if the UART is on, and discard the message if it is off.

    That is at least what I can come up with. The NRF_LOG module is not dynamic.

  • I am not sure if call to log_init function makes a difference in power consumption. I mean we have to set NRF_FPRINTF and NRF_BACKEND_UART_ENABLE to 0 for reducing power consumption. I can change the operation of the device to require reset whenever the switch is toggled, but only if the call to log_init function makes a difference in power consumption. can you verify it ? I can't right now, I don't have access to any measurement tools.  

  • I don't have access to the tools myself. I suspect we're in the same home office situation.

    If you insist on using the NRF_LOG_MODULE, then I suggest that you have another layer with a variable deciding whether to print or not.

    If this variable is true, then you call log_init() and call NRF_LOG_INFO();

    But I believe it would be easier for you use the UART directly.

  • Thanks for your reply, yup we are indeed stuck. Let's see I'll write logic for both and check which consumes less power. I'll let you know.

  • My expectation is that they will draw a similar amount of power, as the NRF_LOG use the UART peripheral, but it is not possible to deinit the NRF_LOG module. Another disadvantage with using the NRF_LOG is that it is a quite large code base, so it will take up quite a bit of flash. I don't know if your project is already using up a lot of flash, but it just sounds more tidy to use the UART, which you will be able to turn off again.

Related