Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Correct use of NRF_LOG for display on Termite

#include <stdbool.h>    //Permite usar funciones booleanas de C++
#include <stdint.h>     //Permite usar funciones generales de C++

#include "nrf.h"
#include <stdbool.h>   
#include <stdint.h>   

#include "nrf.h"
#include "nordic_common.h"
#include "boards.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"  
#include "nrf_log.h"   

/**
 * @brief Function for application main entry.
 */
int main(void)
{
   nrf_gpio_cfg_input(26, NRF_GPIO_PIN_PULLDOWN);

    while (true)
    { 
				NRF_LOG_INFO(26);
    }
}
/** @} */

Hello to everyone.

I have a doubt about the function of NRF_LOG library in nRF52 DK.
I´m trying to display the voltaje value from pin P0.26 on Termite, so I saw in this page that NRF_LOG_ENABLED and NRF_LOG_BACKEND_UART_ENABLED must be in 1 on sdk_config.h, so that´s ready.
Then I try to use NRF_LOG_INFO() to display the value but I found that NRF_LOG_INFO() it´s only for char parameters.
My question is, does NRF_LOG library has a function to be used with integer value or there´s a way to convert int values into char? (line 20).
This project is the "ble_app_blinky_pca10040_s132", so contains its sdk_config.h file, but I replaced the .c file with one mine.
I hope you can help me.

Parents
  • Hi,

    If you want to get the state of the pin, you need to read the pin and store its value to a variable. You can then pass the variable to NRF_LOG:

    uint32_t pin_state = nrf_gpio_pin_read(26);
    NRF_LOG_INFO("Pin state: %d", pin_state);

    NRF_LOG use printf format to format the strings.

    Best regards,
    Jørgen

  • Hello Jorgen, thank you for answer.
    I can compile the program now, but I can´t see anything in Termite. I´m using a sdk_config.h file from an example that doesn´t need SoftDevice (blinky / PCA100040 / blank).
    The original config file didn´t has the NRF_LOG_ENABLED and NRF_LOG_BACKEND_UART_ENABLED lines, so I added them copying from another sdk_config.h file (ble_app_blinky / PCA100040 / s132), but only those two functions.
    I need to copy all the NRF_LOG functions? like BAUDRATE and TEMP_BUFFER_SIZE?
    My question is because I´m not sure I´m using the correct Baudrate to link with Termite.

Reply
  • Hello Jorgen, thank you for answer.
    I can compile the program now, but I can´t see anything in Termite. I´m using a sdk_config.h file from an example that doesn´t need SoftDevice (blinky / PCA100040 / blank).
    The original config file didn´t has the NRF_LOG_ENABLED and NRF_LOG_BACKEND_UART_ENABLED lines, so I added them copying from another sdk_config.h file (ble_app_blinky / PCA100040 / s132), but only those two functions.
    I need to copy all the NRF_LOG functions? like BAUDRATE and TEMP_BUFFER_SIZE?
    My question is because I´m not sure I´m using the correct Baudrate to link with Termite.

Children
No Data
Related