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

Hello,Can anyone help me out by giving me complete details of this?

i would like to print register values of an external sensor on my screen using UART! I'm reading and writing into those registers using SPI! Printing a normal message using NRF_LOG_INFO function is fine, but how do i print the 32bit values of the register using UART?

  • Hi, Yashur.

    RTTExample

    Are you talking something like this?

    Nordic's

    NRF_LOG_INFO, NRF_LOG_WARNING, NRF_LOG_ERROR, and more,

    these can use the printf's format specifier like %d or %x.

    Hope this helps!

    / Edited at 2018.10.12/**

    What MCU and SDK version are you using?

    When using Nordic's logger, you can choose the backend; UART or SEGGER RTT.

    The above picture was an example when using RTT.

    UARTLog

    And this is the result when you choose UART as the backend.

    I have tested this using SDK 14 and PCA10040, which has nRF52832 populated.

    I'm not sure about the version number. Maybe SDK 12 or above uses the sdk_config.h file.

    In there, you can choose whether to use RTT or UART while logging.

    #define NRF_LOG_ENABLED 1
    #define NRF_LOG_BACKEND_UART_ENABLED 1
    #define NRF_LOG_BACKEND_UART_TX_PIN 6
    #define NRF_LOG_BACKEND_UART_BAUDRATE 30801920
    // <30801920=> 115200 baud 
    

    Modify these and I think you will see what you want.

    By the way, do you really have to use UART1, which I think it doesn't exist, to be the logger's backend?

    nRF52832, compared to nRF52840, has UART0 and UARTE0 (Universal asynchronous receiver/transmitter with EasyDMA).

    UART0Reg

    Check the nRF52832 product specification, please.

    I'm guessing that this is using UART0 as the backend.

    -Best Regards, MANGO

  • Hey mango, thanks for your answer! I have tried the above code but i'm getting the following error! saying implicit declaration of function sd_app_evt_wait and also of 'log_init'!!

  • And also i have asked about initialising uart while using SPI! the uart example is running fine but when used with SPI it's throwing an error!! I have tried changing the instances of SPI and UART and i found out that UART1 seems to have a problem working!! Could you help me out with that?

  • Hello, Yashur. About the implicit declaration of function sd_app_evt_wait, if you haven't added or configured Nordic's SoftDevice related files, this error will pop up.

    For instance, when using Nordic's SDK 14, in nrf_soc.h

    enum NRF_SOC_SVCS{ // omit others
    SD_APP_EVT_WAIT,
    
    SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));
    

    are defined. Check whether your header include path is configured correctly.

    This applies to log_init part as well; Check whether your header include path is configured correctly if it includes nrf_log_ctrl.h or more.

    I will add some words to my original answer to help you out with the UART1 problem.

    -Best Regards

Related